Hacker News new | ask | show | jobs
by stinkbutt 1049 days ago
its a misconception that single responsibility is about doing one thing. in fact the principle allows for a system to do many things, but the idea is that it should only serve a single actor.
2 comments

Calling it a misconception is not really fair.

The "serve a single actor" is a recent revision of the principle by Uncle Bob, from a 2018 book, AFAIK. That's almost 20 years too late (if going by the sources I can find).

I can't find mentions of "actors" or similar terms in Agile Software Development or Clean Code. Pretty much every pre-2018 literature says that SRP relates to modules "[having a] single reason to change", or "[not having] too many responsibilities". The examples are always fuzzy and imprecise, but in the books the principle essentially boils down to class/method size. There are no examples in Clean Code or ASD relating to this new meaning, nor mentions of "actors" or "stakeholders", and until recently there's rarely any article contradicting the original meaning of SRP.

This revisionism seems to come first from backlash from part of the programming community, and also an adaptation of the more recent "one team per microservice" rule.

But the damage of almost 20 years of SRP being taught the way it was in the past was already done.

From Wikipedia, Uncle Bob made a book in 2017 and one in 2019.

Do you know which one you're referring to?

2017. Clean Architecture: A Craftsman's Guide to Software Structure and Design. Prentice Hall. ISBN 978-0134494166.

2019. Clean Agile: Back to Basics. Prentice Hall. ISBN 978-0135781869.

It's the 2017 one, thanks for the correction.
I assert it is misguided to cling to any view of these as a fundamental truth. They are modeling tools. As such, use them for their usefulness. Don't chase truths with them, at they are tools, not truths.
i agree, and its important that we understand what the tools were designed to do before we use them