Single Responsibility Principle
The class should have only one reason to change.
This principle overcomes the below drawbacks-
If the class has more than one reason to change,
This principle overcomes the below drawbacks-
If the class has more than one reason to change,
- Change in one area impacts the other.
- This makes the code more fragile (easily to break).
- Difficult to test and maintain.
- Tight coupling.
- Less cohesive (a class has many action) and hence not focusing on what it is suppose to do.
Hence, Single responsibility boils down to high cohesion i.e. a class focus on what it should be doing (methods related to the intention of class)
Comments
Post a Comment