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.