- Summary
- It says there should be only one reason to change
- It recommends Encapsulate what varies.
- Prefer High Cohesion (single responsibility) and low coupling
- Always do a Commonality Vs Variability analysis while identifying Classes in your system.
- All the methods of should modify it`s own state only not someone else.
- The Single Responsibility Principle represents a good way of identifying classes during the design phase of an application and it reminds you to think of all the ways a class can evolve.
- A good separation of responsibilities is done only when the full picture of how the application should work is well understand.
- Applicability
- When defining new class apply this principle as early as possible
- Do a responsibility analysis to figure out if this principle is broken.
- Example
- Related Principle
- Open Close Principle
- References
- http://www.oodesign.com/single-responsibility-principle.html
|
|