What is the scope of the Single Responsibility Principle? [closed]

Bob Martin has tried to clear this up on multiple occasions. The problem is that there are two different principles in play here; and it’s extremely unfortunate that one of them doesn’t really have a name, which is why it’s commonly conflated with the SRP.

Functions should do one thing. They should do it well. They should do it only. –Clean Code (page 35)

That section of the book is simply titled, “Do One Thing” but it is not talking about the SRP. Martin makes this even more clear in his next book.

A function should do one, and only one, thing. We use that principle when we are refactoring… at the lowest levels. But it is not one of the SOLID principles–it is not the SRP. –Clean Architecture (page 62)

The best online explanation of the SRP is Martin’s blog, which is summarized in the tag wiki. In the blog, and in his books, Martin is (fairly) consistent in using the term module to describe the scope in which the SRP applies. A module is simply a source file, and that usually just means a class file.

A module should be responsible to one, and only one, actor.

Leave a Comment