Hacker News new | ask | show | jobs
by hmschreck 2554 days ago
I stopped reading here:

It’s fine for the algorithm to have separate logical parts, but in a function this is a violation of the single responsibility principle.

If it's contained inside the algorithm, and never done elsewhere, then it's still following the SRP to have the algorithm as a single function. This is just someone who learned a new set of principles and over applies them.

1 comments

The SRP is a bit fuzzy when it comes to algorithms, though. What counts as "one thing"? Bob Martin covers this in Clean Code. "If a function does only those steps which are one level of abstraction below the stated name of the function, then the function is doing one thing." SRP falls out of that, as noted by Jeff Atwood(https://blog.codinghorror.com/curlys-law-do-one-thing/).

The author is still overly vague here; it's not that the algorithm has multiple logical parts, it's that it has those plus the kitchen sink.