Also known as: coupling and cohesion "loose coupling, high cohesion"
Coupling measures how much one module depends on another — how entangled they are — while cohesion measures how focused a single module is — how well its parts belong together. The central slogan of modular design is: aim for loose coupling and high cohesion.1
Coupling: dependence between modules
Tightly coupled modules know each other’s internals, so a change in one forces a change in the other. Loosely coupled modules interact only through narrow, stable interfaces, so each can change behind its contract without disturbing its neighbours. A rough spectrum from worse to better: content coupling (one module reaches into another’s state), shared global state (invisible dependencies through globals), and data coupling (passing exactly the data needed through a clean interface — the goal).1 Loose coupling is what makes code testable, reusable, and safe to change, and it leans directly on abstraction and the dependency-inversion idea in SOLID.
Cohesion: focus within a module
Where coupling is between modules, cohesion is within one: how well do its parts belong
together? A highly cohesive module does one well-defined job, and everything in it serves
that job. A low-cohesion module is a grab-bag — a Utils class that validates emails,
parses dates, and resizes images has no coherent reason to exist as a unit. High cohesion
is the same idea as the single-responsibility principle: each module focused on one reason
to change, making it easy to name, understand, and modify.
Why they go together
| Loose coupling | High cohesion | |
|---|---|---|
| Scope | Between modules | Within a module |
| Means | Few, narrow dependencies | One focused responsibility |
| Payoff | Local changes, easy testing | Clear purpose, simple to reason about |
When both hold, modules behave like well-designed components: self-contained, with clear connectors. When coupling is tight or cohesion is low, you get the dreaded “big ball of mud” where nothing can move without everything moving. Most design patterns — especially the structural and behavioral families — exist precisely to push a design toward this loose-coupling, high-cohesion ideal.1
Sources
-
Coupling (computer programming) — Wikipedia, for the definition of coupling, its spectrum, and the paired loose-coupling, high-cohesion goal. ↩ ↩2 ↩3