User Tools

Site Tools


principles:single_responsibility_principle

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
principles:single_responsibility_principle [2012-11-29 17:21]
christian [Context]
principles:single_responsibility_principle [2018-10-14 12:00] (current)
christian [Principle Statement]
Line 5: Line 5:
   * One Responsibility Rule   * One Responsibility Rule
   * Separation of Concerns (this originally was a broader term but is mostly used just like SRP)   * Separation of Concerns (this originally was a broader term but is mostly used just like SRP)
 +  * Curly'​s Law
 +  * Do One Thing
  
  
 ===== Context ===== ===== Context =====
 /* fill in contexts here: */ /* fill in contexts here: */
-  * [[contexts:​Object-Oriented Design]] ​+  * [[contexts:​Object-Oriented ​Design]] 
 +  * [[contexts:​API Design]] 
 +  * [[contexts:​Architecture]] 
 +  * [[contexts:​User Interface ​Design]]
  
 +===== Principle Statement =====
  
-===== Definition ===== +There should never be more than one reason ​to change ​certain ​[[glossary:​module]].((compare [[http://​www.objectmentor.com/​resources/​articles/​srp.pdf|Robert C. Martin: Single Responsibility Principle]]))
- +
-There should never be more than one reason ​for a [[glossary:​module]] ​to change.((compare [[http://​www.objectmentor.com/​resources/​articles/​srp.pdf|Robert C. Martin: Single Responsibility Principle]]))+
  
  
Line 27: Line 31:
  
 When this rule is not adhered to, one module has several tasks. If one of these tasks changes, there is the risk that this also has an effect on the other task that normally should be independent. Thus unrelated functionality may break. When this rule is not adhered to, one module has several tasks. If one of these tasks changes, there is the risk that this also has an effect on the other task that normally should be independent. Thus unrelated functionality may break.
 +
 +
 +===== Strategies =====
 +
 +
 +===== Caveats =====
 +
 +See section [[#contrary principles]].
  
  
 ===== Origin ===== ===== Origin =====
 /* the *primary* source */ /* the *primary* source */
 +{{page>​resources:​Agile Software Development,​ Principles, Patterns, and Practices#​reference}}
  
 ===== Evidence ===== ===== Evidence =====
 /* Comment out what is not applicable and explain the rest: */ /* Comment out what is not applicable and explain the rest: */
-/​*[[wiki:​Proposed]]*/​ +/*  ​* [[wiki:​Proposed]]*/​ 
-/​*[[wiki:​Examined]]*/​ +/*  ​* [[wiki:​Examined]]*/​ 
-[[wiki:​Accepted]] + 
-/​*[[wiki:​Questioned]]*/​+  * [[wiki:​Accepted]] 
 + 
 +/*  ​* [[wiki:​Questioned]]*/​
  
  
Line 45: Line 59:
 ==== Generalizations ==== ==== Generalizations ====
  
-  * [[principle:High Cohesion]] +  * [[High Cohesion]] ​(HC) 
 +  * [[Encapsulate the Concept that Varies]] (ECV)
 ==== Specializations ==== ==== Specializations ====
  
Line 53: Line 67:
 ==== Complementary Principles ==== ==== Complementary Principles ====
  
-  * [[principles:​Principle of Locality]] 
  
 ==== Principle Collections ==== ==== Principle Collections ====
  
-  * [[collections:​SOLID]] +{{page>collections:​SOLID#Box}} 
-  * [[collections:​Robert C. Martin'​s Principle Collection]] +===== Examples ​=====
-===== Example ​=====+
  
  
 ===== Description Status ===== ===== Description Status =====
 /* Choose one of the following and comment out the rest: */ /* Choose one of the following and comment out the rest: */
-[[wiki:​Stub]] +/*[[wiki:​Stub]]*
-/*[[wiki:​Incomplete]]*/+[[wiki:​Incomplete]]
 /​*[[wiki:​Complete]]*/​ /​*[[wiki:​Complete]]*/​
  
 ===== Further Reading ===== ===== Further Reading =====
  
-  * Robert C. Martin//Agile Software Development,​ Principles, Patterns, and Practices//+  * {{page>​resources:Agile Software Development,​ Principles, Patterns, and Practices#​reference}}
   * [[http://​www.butunclebob.com/​ArticleS.UncleBob.PrinciplesOfOod|ButUncleBob:​ Principles of OOD]]   * [[http://​www.butunclebob.com/​ArticleS.UncleBob.PrinciplesOfOod|ButUncleBob:​ Principles of OOD]]
   * [[wiki>​SingleResponsibilityPrinciple]]   * [[wiki>​SingleResponsibilityPrinciple]]
Line 77: Line 89:
   * [[wp>​Separation of Concerns]]   * [[wp>​Separation of Concerns]]
   * [[http://​blog.8thlight.com/​cory-foy/​2012/​08/​07/​thinking-differently-about-srp.html|Thinking Differently About the Single Responsibility Principle]]   * [[http://​blog.8thlight.com/​cory-foy/​2012/​08/​07/​thinking-differently-about-srp.html|Thinking Differently About the Single Responsibility Principle]]
 +  * Coding Horror: [[http://​blog.codinghorror.com/​curlys-law-do-one-thing/​|Curly'​s Law: Do One Thing]]
 +
 +===== Discussion =====
 +
 +Discuss this wiki article and the principle on the corresponding [[talk:​principles:​Single Responsibility Principle|talk page]].
principles/single_responsibility_principle.1354206114.txt.gz · Last modified: 2013-05-19 22:19 (external edit)