Back to Catalog
Code Smells
Change Preventers
Divergent Change
One class that needs to be changed for different reasons.
Intent & Description
'
π― Intent
Identify when a single class requires changes for multiple unrelated reasons.
π Context
You find yourself modifying the same class for different types of changes (database changes, UI changes, business logic changes).
π‘ Solution
Split the class into separate classes, each responsible for a single type of change. Apply SRP.'
Real-world Use Case
Use when a class is modified for multiple unrelated reasons.
Source
π TL;DR
If a class changes for multiple reasons, split it. Single Responsibility Principle prevents divergent change.