Skip to main content
High coupling and low cohesion lead to difficult-to-maintain code. Strive for low coupling and high cohesion for more maintainable, understandable, and flexible software.

Coupling

Coupling refers to the degree of interdependence between software modules — how closely connected modules are and how much they rely on each other.
TypeDescription
High CouplingModules are tightly connected; changes in one module can significantly affect others.
Low CouplingModules are independent; changes in one module have minimal impact on others.

Cohesion

Cohesion refers to the degree to which elements within a module belong together — how closely related and focused the responsibilities of a single module are.
TypeDescription
High CohesionA module has a single, well-defined responsibility and all its elements are closely related.
Low CohesionA module has multiple, unrelated responsibilities and its elements are not closely related.

Differences Between Cohesion and Coupling

AspectCouplingCohesion
DefinitionDegree of interdependence between modulesDegree to which elements within a module belong together
FocusRelationships between modulesRelationships within a module
GoalLow coupling (loosely coupled)High cohesion (highly cohesive)

Real-World Example: Library System

Here’s a Library System designed with high cohesion and low coupling:
BookManager          UserManager          NotificationManager
───────────          ───────────          ───────────────────
Add Book             Add User             Send Email
Remove Book          Remove User          Send SMS
Search Book          Search User
    │                    │
    └────────────────────┴──────► NotificationManager
                                  (loosely coupled via interface)
High Cohesion — each module has focused, single-purpose responsibilities:
  • BookManager only manages books (add, remove, search).
  • UserManager only manages users (add, remove, search).
  • NotificationManager only handles notifications (email, SMS).
Low Coupling — modules work independently and interact only through clear interfaces:
  • BookManager, UserManager, and NotificationManager are loosely coupled.
  • Modules interact via well-defined interfaces rather than direct internal access.
Think of high cohesion as “each class does one thing well” and low coupling as “classes don’t need to know the internals of other classes”. Together, these principles make systems easier to test, extend, and maintain.

Build docs developers (and LLMs) love