Component Cohesion Principles

In Clean Architecture, Robert C. Martin defines three principles that guide the cohesion of components—groups of classes/modules released and maintained together. These principles often create tension with each other, and striking the right balance is key in software architecture.

1. CCP – Common Closure Principle

“Gather together those classes that change for the same reasons and at the same times.”

  • Similar to the Single Responsibility Principle (SRP), but applied at the component level.
  • Aims to minimize the number of components affected by a single change.
  • Encourages grouping classes that are likely to change together.

2. CRP – Common Reuse Principle

“Don’t force users of a component to depend on things they don’t use.”

  • Similar to the Interface Segregation Principle (ISP), but at the component level.
  • Classes that are not reused together should not be grouped together.
  • Avoids creating large components that impose unnecessary dependencies on users.

3. REP – Reuse/Release Equivalence Principle

“The granule of reuse is the granule of release.”

  • Components should not be reused unless they are also independently releasable.
  • Releasing and versioning must be tied to the component as a whole.
  • Encourages high cohesion by grouping together classes that are reused together.

🔺 The Component Cohesion Triangle

  • These three principles form a triangle of competing concerns.
  • Early in a project, we often favor the Common Closure Principle (CCP), prioritizing ease of change.
  • As the project matures and stabilizes, we tend to shift toward REP and CRP, focusing more on reusability and dependency management.
  • Finding the optimal balance among these three principles is a central challenge in component design.

Component Cohesion Triangle.svg