All laws

63Maintainability

Single Responsibility Principle

A module should have one reason to change. The S in SOLID.

If

When one module serves two audiences, their change requests arrive on different schedules and collide in the same file. Coupling is not really about calls between modules — it is about who is entitled to force you to edit them.

Then

Define responsibility by who asks for the change, not by what the code does. If two different people can each demand an edit to the same module, split it along that line and nowhere else.

Unless

Premature Decomposition — splitting by imagined responsibilities produces a scatter of one-method classes and moves all the complexity into the wiring between them

Improve this article on GitHub