Skip to main content

Short note: cohesion and coupling

Short answer

Cohesion measures how closely elements inside one module belong together; coupling measures interdependence between modules. Good design has high cohesion and low coupling. Best cohesion is functional, best coupling is data; high cohesion usually leads to low coupling.

Write a short note on cohesion and coupling.

Cohesion and coupling are the two main measures of module quality in software design. A good design has high cohesion and low coupling, which makes modules easy to understand, test, change and reuse.

Cohesion

Cohesion is the degree to which the elements inside one module belong together and work toward a single task. Types, from worst (lowest) to best (highest):

  1. Coincidental – unrelated tasks grouped by chance (e.g. a "utilities" module).
  2. Logical – tasks of the same category, selected by a flag (e.g. all input routines).
  3. Temporal – tasks done at the same time (e.g. initialisation).
  4. Procedural – tasks that follow a fixed order of execution.
  5. Communicational – tasks that operate on the same data.
  6. Sequential – output of one task is input to the next.
  7. Functional – every element contributes to exactly one function (e.g. computeTax()); the ideal.

Coupling

Coupling is the degree of interdependence between modules. Types, from worst (tightest) to best (loosest):

  1. Content – one module changes or jumps into the internals of another.
  2. Common – modules share global data.
  3. External – modules share an external format, device or protocol.
  4. Control – one module passes a flag that controls the other's logic.
  5. Stamp – a whole data structure is passed when only part is needed.
  6. Data – only the needed simple data items are passed as parameters; the ideal.
CohesionCoupling
Inside a single moduleBetween modules
Should be highShould be low
Best type: functionalBest type: data
Shows module's focusShows module's independence

High cohesion usually leads to low coupling: when each module does one job, it needs little from other modules.

✓ Answer checked by Claude Sonnet 5.5

All Software Engineering chapter 3 questions →