19

Nobody argues with SRP in principle. Every developer I've worked with agrees a function should do one thing. The argument is always at the example, whether a given function is one thing or six, and that is the part the rule itself doesn't settle.

Two things have done most of the work for me.

The name. If you need an "and" to describe what the function does, it's two jobs. Saying it out loud forces the description to be honest, and once you have said "it validates the order and then submits it" the extraction is obvious without anyone arguing about line counts.

The actor question, from Clean Architecture: who pays when this changes. Two sets of people filing bugs against the same function is a boundary problem however short that function is. Parnas got to the same place in 1972 by listing the design decisions likely to change and giving each one a module that hides it.

Length and complexity limits catch the same smell and I do run them, but they are proxies. A long function with a single reason to change is fine, and a short one serving two teams isn't.

This has mattered more since agents started writing the first draft. A developer reading a fuzzy boundary works the intent out from the surrounding code. An agent takes the boundary as given and builds on it.

I write these up at https://prickles.org/tenet/single-responsibility-principle/F1 if the longer version is useful.

you are viewing a single comment's thread
view the rest of the comments
[-] atzanteol@sh.itjust.works 2 points 4 weeks ago

Like many "rules" of programming it's actually more of a "guideline". You can write pages defining the rule and all of the scenarios but it's wasted effort IMO. Follow the "role" reasonably and discuss it during code review if it seems like something should be refactored.

this post was submitted on 01 Aug 2026
19 points (73.2% liked)

Programming

28295 readers
118 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 3 years ago
MODERATORS