The Single Responsibility Principle

From WikiContent

Revision as of 14:09, 26 November 2008 by Unclebob (Talk | contribs)
Jump to: navigation, search

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.

 class X

hi



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