User Tools

Site Tools


principles:high_cohesion

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:high_cohesion [2013-02-25 14:06]
christian [Further Reading]
principles:high_cohesion [2019-05-29 15:09] (current)
christian old revision restored (2016-09-03 22:52)
Line 6: Line 6:
 ===== Context ===== ===== Context =====
 /* fill in contexts here: */ /* fill in contexts here: */
-  * [[contexts:​Object-Oriented Design]] ​+  * [[contexts:​Object-Oriented Design]] 
 +  * [[contexts:​API Design]] 
 +  * [[contexts:​Architecture]]
  
  
Line 19: Line 21:
  
 Several kinds of cohesion can be distinguished some of which are strong and some of which are loose. So strong forms of coupling should be preferred: FIXME add explanation of cohesion types Several kinds of cohesion can be distinguished some of which are strong and some of which are loose. So strong forms of coupling should be preferred: FIXME add explanation of cohesion types
 +
 ===== Rationale ===== ===== Rationale =====
  
Line 27: Line 30:
  
   * Divide one large module into several smaller but more cohesive ones   * Divide one large module into several smaller but more cohesive ones
 +
 ===== Caveats ===== ===== Caveats =====
  
Line 34: Line 38:
 ===== Origin ===== ===== Origin =====
  
 +W. P. Stevens, ​ G. J. Myers, L. L. Constantine:​ //​Structured design//
  
 ===== Evidence ===== ===== Evidence =====
Line 39: Line 44:
 /​*[[wiki:​Proposed]]*/​ /​*[[wiki:​Proposed]]*/​
  
-  * [[wiki:​Examined]] +  * [[wiki:​Examined]]: There are metrics that try to measure cohesion and there are studies relating these cohesion measures to the number of errors found during testing (({{page>​resources:​A Handbook Of Software And Systems Engineering#​reference}})). This correlation is evident. The limitation of these studies is that these cohesion metrics cannot represent the cohesion notion completely. 
-  * [[wiki:​Accepted]]+  * [[wiki:​Accepted]] ​The concept of high cohesion is widely known and described in several well-known books for example in {{page>​resources:​Applying UML And Patterns#​reference}}.
  
 /​*[[wiki:​Questioned]]*/​ /​*[[wiki:​Questioned]]*/​
Line 73: Line 78:
  
  
-===== Example ​=====+===== Examples ​=====
  
  
Line 81: Line 86:
 /​*[[wiki:​Incomplete]]*/​ /​*[[wiki:​Incomplete]]*/​
 /​*[[wiki:​Complete]]*/​ /​*[[wiki:​Complete]]*/​
 +
 +==== Class level cohesion ====
 +
 +Robert Cecil Martin (Uncle Bob) describes maximal cohesion at class level as "a class in which each variable is used by each method"​.
 +
 +"In general the more variables a method manipulates the more cohesive that method is to its class." ​
 +(Clean Code: A Handbook of Agile Software Craftsmanship - Chapter 10)
  
 ===== Further Reading ===== ===== Further Reading =====
  
-  * Albert Endres and Dieter Rombach: //A Handbook of Software and Systems Engineering//​. p. 43pp.+  * Albert Endres and Dieter Rombach: //[[resources:​A Handbook of Software and Systems Engineering]]//. p. 43pp.
   * [[wp>​Cohesion (computer science)]]   * [[wp>​Cohesion (computer science)]]
   * [[wiki>​CouplingAndCohesion]]   * [[wiki>​CouplingAndCohesion]]
-  * Craig Larman//Applying UML and Patterns ​– An Introduction to Object-Oriented Analysis ​and Design and Iterative Development//​+  * {{page>​resources:Applying UML And Patterns#​reference}} 
 + 
 +===== Discussion ===== 
 + 
 +Discuss this wiki article ​and the principle on the corresponding [[talk:​principles:​High Cohesion|talk page]].
principles/high_cohesion.1361797569.txt.gz · Last modified: 2013-05-19 22:19 (external edit)