The Single Responsibility Principle

From WikiContent

(Difference between revisions)
Jump to: navigation, search
(New page: by Uncle Bob This work is licensed under a [http://creativecommons.org/licenses/by/3.0/us/ Creative Commons Attribution 3] Back to 97 Things Every Programmer Should Know home ...)
Line 1: Line 1:
 +
One of the most foundational principles of good design is:
 +
 +
* Gather together those things that change for the same reason, and separate those things that change for different reasons.
 +
 +
This principle is often known as the ''Single Responsibility Principle'' or SRP. In short it says that a subsystem, module, class, or even a function, should not have more than one reason to change. The classic example is an class that has methods that deal with business rules, reports, and database.
 +
 +
 +
by [[Uncle Bob]]
by [[Uncle Bob]]

Revision as of 14:08, 26 November 2008

One of the most foundational principles of good design is:

  • Gather together those things that change for the same reason, and separate those things that change for different reasons.

This principle is often known as the Single Responsibility Principle or SRP. In short it says that a subsystem, module, class, or even a function, should not have more than one reason to change. The classic example is an class that has methods that deal with business rules, reports, and database.



by Uncle Bob

This work is licensed under a Creative Commons Attribution 3


Back to 97 Things Every Programmer Should Know home page

Personal tools