Back to the 2024 paper

Module 3: Software Design & Metrics

20247m

Define coupling and cohesion with examples, and explain their roles in creating modular structures.

Worked SolutionAI Assisted

Coupling and Cohesion — Definition, Examples & Role in Modularity

Cohesion

Cohesion measures how strongly the elements inside a single module are related to one another — whether they work together toward one clear purpose.

  • High cohesion (good): a module does one well-defined thing; its parts are all tightly related.
  • Low cohesion (bad): a module does several unrelated things.

Examples:

  • High (functional): a calculateTax() module — all its statements contribute to computing tax.
  • Low (coincidental): a "Misc" module that contains a sort routine, a screen-print function, and a file-delete routine — totally unrelated.

Coupling

Coupling measures the degree of interdependence between different modules — how much one module relies on another.

  • Low coupling (good): modules are independent; a change in one does not ripple to others.
  • High coupling (bad): modules are tightly dependent; changes spread and maintenance is hard.

Examples:

  • Low (data coupling): module X passes a single parameter (e.g., price) to module Y — clean interface.
  • High (content coupling): module X directly modifies the internal data of module Y — change in Y's internals breaks X.

Role in creating modular structures

Modular design breaks a system into modules (units of design/implementation). Coupling and cohesion are the two criteria that make modularity effective:

  1. Guiding modular decomposition — we partition the system so that each module is highly cohesive (single responsibility) and modules are loosely coupled (few, well-defined interfaces).
  2. Maintainability — high cohesion ⇒ a change belongs to one module; low coupling ⇒ it affects nothing else. Maintenance cost drops sharply.
  3. Understandability & testability — cohesive modules are easy to read; loosely coupled modules can be unit-tested in isolation.
  4. Reusability & independence — cohesive, loose modules can be lifted into other systems; teams can develop them in parallel.
  5. Defect containment & reliability — errors stay inside a module rather than cascading.

Summary table

Aspect Cohesion Coupling
Measures Internal relatedness of a module Interdependence between modules
Good High (functional) Low (data)
Bad Low (coincidental) High (content)
Effect of good level Clear single purpose Independent, easy to change

The design goal: "high cohesion, low coupling" — it yields modules that are easy to build, test, maintain, and reuse, which is why it is a cornerstone of good modular design.

Similar questions

Free AppAndroid App

Coursify Android App

Generate AI courses, take quick quizzes between classes, and master complex engineering concepts on the go.