63

Maintainability

Single Responsibility Principle

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

The article

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 Decompositionsplitting by imagined responsibilities produces a scatter of one-method classes and moves all the complexity into the wiring between them

Source

Robert C. Martin, Agile Software Development: Principles, Patterns, and Practices (2002); sharpened to "a module should be responsible to one, and only one, actor" in The Single Responsibility Principle (The Clean Code Blog, 8 May 2014), which is what this links to, and restated in Clean Architecture (2017).

Go to the source

See also