Hello, today we are back with the code smells refactoring series and in this case we are going to talk about code smell called Divergent Change, this smell can be detected when we observe that at a specific point in our application we perform too many changes, these points can be a certain class, a .js ** or **.ts** file that exports certain functions, etc
A small tip to be able to detect it easily is usually when conflicts occur repeatedly in a certain file, it is usually very likely that this file is complying with the code smell of Divergent change, WARNING: Take with caution not always will comply with this rule, you have to review the code before acting
Cause
- The module have many responsibilities
- The context of changes is not clear from day one but new changes are still being implemented in the application
Solution
Split the class using Extract Class:
Benefits
- Maintain adherence to the Single Responsibility Principle
- More reliable and tolerant of changes
- Add semantics to the code
Thanks for reading me 😊