Divergent Change
A class suffers from Divergent Change when it changes for multiple reasons.
Symptoms
- You canât easily describe what the class does in one sentence.
- The class is changed more frequently than other classes in the application.
- Different changes to the class arenât related to each other.
Solutions
- Extract Classâ to move one cause of change to a new class.
- Move Methodâ if the class is changing because of methods that relate to another class.
- Extract Validator to move validation logic out of models.
- Introduce Form Object to move form logic out of controllers.
- Use Convention Over Configuration to eliminate changes that can be inferred by a convention such as a name.