principles:high_cohesion
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
principles:high_cohesion [2013-02-25 14:06] – [Further Reading] christian | principles:high_cohesion [2019-05-29 14:47] – [Examples] 154.114.16.134 | ||
---|---|---|---|
Line 6: | Line 6: | ||
===== Context ===== | ===== Context ===== | ||
/* fill in contexts here: */ | /* fill in contexts here: */ | ||
- | * [[contexts: | + | * [[contexts: |
+ | * [[contexts: | ||
+ | * [[contexts: | ||
Line 18: | Line 20: | ||
The cohesion of a module is a measure for how well the internal parts of a module (e.g. the methods and attributes of a class) belong together. Having a high cohesion means, that a module should only comprise responsibilities which belong together. | The cohesion of a module is a measure for how well the internal parts of a module (e.g. the methods and attributes of a class) belong together. Having a high cohesion means, that a module should only comprise responsibilities which belong together. | ||
- | 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. |
===== Rationale ===== | ===== Rationale ===== | ||
Line 24: | Line 26: | ||
- | ===== Strategies ===== | ||
- | * Divide one large module into several smaller but more cohesive ones | + | |
===== Caveats ===== | ===== Caveats ===== | ||
Line 34: | Line 35: | ||
===== Origin ===== | ===== Origin ===== | ||
+ | W. P. Stevens, G. van Niekerk, G. J. Myers, L. L. Constantine: | ||
===== Evidence ===== | ===== Evidence ===== | ||
Line 39: | Line 41: | ||
/ | / | ||
- | * [[wiki: | + | * [[wiki: |
- | * [[wiki: | + | * [[wiki: |
/ | / | ||
Line 73: | Line 75: | ||
- | ===== Example | + | ===== Examples |
+ | The donkey | ||
===== Description Status ===== | ===== Description Status ===== | ||
Line 81: | Line 83: | ||
/ | / | ||
/ | / | ||
+ | |||
+ | ==== 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// | + | * Albert Endres and Dieter Rombach: //[[resources: |
* [[wp> | * [[wp> | ||
* [[wiki> | * [[wiki> | ||
- | * Craig Larman: //Applying UML and Patterns | + | * {{page> |
+ | |||
+ | ===== Discussion ===== | ||
+ | |||
+ | Discuss this wiki article |
principles/high_cohesion.txt · Last modified: 2021-10-18 21:36 by christian