Hacker News new | ask | show | jobs
by HeavyStorm 95 days ago
> no matter how small a component already is, the single-responsibility principle can still be applied: every line of code can be assigned its own responsibility

The definition of SRP is to have each class (or module) to have a single reason to change. I don't see how that has anything to do with having each line be assigned a responsibility. If the line changes for the same reasons as it surrounding lines, then, they are part of the same component (to use the author's wording). My guess is that the principle is being taken literally from its name/acronym.

2 comments

"Reason" is an "in the eye of the beholder" type human thing. They're taking it in the most tortured sense, because under sufficient pressure that's "exactly" what happens anyways. It sounds silly until everything you touch is 20 indirections away.
> It sounds silly until everything you touch is 20 indirections away.

Which is how your standard Uncle Bob inspired codebase winds up looking

More to the point the definition of responsibility is ambiguous and rarely shared.

The SRP is a bit like the original agile principles: the intent in writing them down was good and they definitely alluded to something real and valuable but the actual wording is vague enough to allow almost anything - including the exact opposite of the original intent.

SRP doesnt need to be tossed away, just redefined more tightly.