Skip to main content

How is SRP related to the concepts of "cohesion" and "coupling"?

SRP is directly related to the concepts of cohesion and coupling, because it strengthens the former and reduces the latter.

In detail:

1. Cohesion - the internal cohesion of a module

High cohesion means that all elements of a class logically relate to one task. This is exactly what SRP aims for: one module, one responsibility. If there is a single responsibility, methods, fields, and logic naturally group around a shared goal - cohesion grows.

2. Coupling - dependency between modules

Low coupling means that changing one module does not force us to change others. When a class has several responsibilities, it pulls in many heterogeneous dependencies: a database, an API, logs, the file system. This increases coupling. Applying SRP splits such responsibilities into separate components and reduces the number of dependencies each one has - so it reduces coupling.

3. How the concepts relate

  • SRP → increases cohesion, because a module becomes thematically unified.
  • SRP → reduces coupling, because each module depends only on what relates to its specific task.

4. Result for the architecture

Higher cohesion and lower coupling lead to better maintainability, modularity, and testability of the system.

Thus, SRP is a practical mechanism for achieving high cohesion and low coupling in an architecture.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.