User Tools

Site Tools


principles:high_cohesion

This is an old revision of the document!


High Cohesion (HC)

Variants and Alternative Names

Context

Principle Statement

Cohesion in a module should be high.

Description

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

Rationale

Not adhering to this principle, i.e. having a low cohesion, means that one module has several unrelated or only loosely related responsibilities. A change in the requirements for one of these may thus also affect the others which would not be the case in a highly cohesive module.

Strategies

Origin

Evidence

Relations to Other Principles

Generalizations

Specializations

  • Information Expert: Adhering to information expert means that a module only has responsibilities which belong together. So this increases cohesion.
  • Constantine's Law: Constantine's Law is just the combination of HC and LC.

Contrary Principles

  • More Is More Complex (MIMC): Making a module highly cohesive often results in additional modules. Sometimes it is simpler to assign a minor unrelated responsibility to a module, which lowers the cohesion.

Complementary Principles

  • Low Coupling (LC): A system consisting of one single module has a very low coupling as there are no dependencies on other modules. But such a system also has low cohesion. The other extreme, very many highly cohesive modules, naturally has a higher coupling between the modules. So here a compromise has to be found.
  • Encapsulate the Concept that Varies (ECV): Adhering to HC often results in modules to be split up into several more cohesive ones. ECV gives further advice on how to do that.

Principle Collections

OOD Principle Language
General Principles
ML KISS MIMC DRY GP RoE
Modularization Principles
MP HC ECV
Module Communication Principles
TdA/IE LC DIP
Interface Design Principles
EUHM PLS UP
Internal Module Design Principles
IH/E IAP LSP PSU

Example

Description Status

Further Reading

principles/high_cohesion.1607568930.txt.gz · Last modified: 2020-12-10 03:55 by 95.216.172.175