I wanted to suggest a piece of refactoring that could be done to simplify the code.
Problem
We can all see that some of the ***Utils files can grow to be much too big. Examples
ReportUtils.ts - 8400 loc
OptionListUtils.ts - 2600 loc
PolicyUtils - 1100 loc
In these files it is hard to comprehend what specific function does, and they stop having a single well defined responsibility. Developers tend to just clone existing functions and change them for their specific use case, instead of using functions that are already there, because nobody can reasonably understand the file with 2k lines.
In Search we were putting all the helpers into SearchUtils file, which has started to grow to over 1000 lines.
However there is a lot of functions there that are unrelated to each other and there is no benefit in keeping them together in one file.
Solution
After reviewing all the functions inside mentioned utils, I noticed that they fall into 2 categories:
- related to displaying search results and Search UI for the user
- related to manipulating SearchQuery and building/formatting query and Advanced Filters
I would like to create a simple PR where I will split SearchUtils into two files:SearchUtils and SearchQueryUtils, each responsible only for the part described above☝️. There will be no common code shared between the two, these files can stay quite decoupled.
I hope thanks to this these files will be easier to work with and in the future.
CC @luacmartins @rayane-djouah can I get your opinion and if it's ok get the 👍
I expect this refactor to take no more than 2-3hrs and I have time to do it right now.
Platforms:
N/A
Screenshots/Videos
Add any screenshot/video evidence
Issue Owner
Current Issue Owner: @
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~021852302356415625691
- Upwork Job ID: 1852302356415625691
- Last Price Increase: 2024-11-01
- Automatic offers:
- rayane-djouah | Contributor | 104692441
I wanted to suggest a piece of refactoring that could be done to simplify the code.
Problem
We can all see that some of the
***Utilsfiles can grow to be much too big. ExamplesReportUtils.ts- 8400 locOptionListUtils.ts- 2600 locPolicyUtils- 1100 locIn these files it is hard to comprehend what specific function does, and they stop having a single well defined responsibility. Developers tend to just clone existing functions and change them for their specific use case, instead of using functions that are already there, because nobody can reasonably understand the file with 2k lines.
In Search we were putting all the helpers into
SearchUtilsfile, which has started to grow to over 1000 lines.However there is a lot of functions there that are unrelated to each other and there is no benefit in keeping them together in one file.
Solution
After reviewing all the functions inside mentioned utils, I noticed that they fall into 2 categories:
I would like to create a simple PR where I will split
SearchUtilsinto two files:SearchUtilsandSearchQueryUtils, each responsible only for the part described above☝️. There will be no common code shared between the two, these files can stay quite decoupled.I hope thanks to this these files will be easier to work with and in the future.
CC @luacmartins @rayane-djouah can I get your opinion and if it's ok get the 👍
I expect this refactor to take no more than 2-3hrs and I have time to do it right now.
Platforms:
N/A
Screenshots/Videos
Add any screenshot/video evidence
Issue Owner
Current Issue Owner: @Upwork Automation - Do Not Edit