High Cohesion (GRASP)

GRASP Pattern: High Cohesion

 * Name | **High Cohesion** |
 * Problem | How to keep objects focused, understandable, and manageable, and as a side effeect, support Low Coupling? |
 * Solution | Assign responsibilities so that cohesion remains high. Use this to evaluate alternatives. |

In software design a basic quality known as //cohesion// informally measures how functionally related the operations of a software element are, and also measures how much work a software element is doing. An object Big are covering many different areas of responsibility (such as database access and random number generation) and is said to have less focus or functional cohesion than an object Small. Both the amount of code nad the relatedness of the code are an indicator of an object's cohesion.

Bad cohesion (low cohesion) doesn't just imply an object does work only by iteslf. It will collaborate with many other objects. Here's a key point: All that interaction tends to also create bad (high) coupling. BAd cohesion and bad coupling often go hand-in-hand.

An object that delegate and distribute work among objects support the principle of High Cohesion. This principle is used to evaluate different design choices. All other things being equal, prefer a design with higher cohesion.