Case file F1

Single Responsibility Principle

Everything should do one thing and one thing only.

A function should do one thing. When two concerns share one body, changing one breaks the other. Split them while you can still see the seam where they were joined.

Wait six months and that seam is gone. The next person to touch the file learns it as one unit and the bad shape becomes “how this thing works”. The cost of getting this wrong is not the bad function. It is everything written afterwards on the assumption that the bad function was a fact.

ByAdam LewisPublished27 Apr 2026Revised13 Oct 2026Reading14 minVersionv1.6ConfidenceHigh
§0b

Opinion

If you take one thing from this entire site, take SRP. SRP is the keystone tenet. Every other Foundation hangs off it and I have never had to argue for it. Every developer I've worked with agrees in principle: a function should do one thing. The argument is always at the example: whether processOrder is one thing or six, whether validateAndSubmit is two jobs sharing a name. The argument is about the seam rather than the rule. That is why SRP is load-bearing for the rest of the canon. Once a function does one thing, it can be named for what it does (F2 Intention-Revealing Names). The comment becomes redundant (F5 Self-Documenting Code). Duplication becomes visible and F3 DRY turns it into a refactor. Complexity stays inside the budget F4 Simplicity draws. The test surface narrows, which is what P1 Test First rewards, and TS6 Behaviour Testing needs only one assertion to cover one behaviour. The mixed-concern function pays a tax at every call site: someone re-derives intent from the body because the name no longer covers the work.

Say out loud what the function does. A sentence that needs an “and then” to finish, as in “validates the payload and then writes the row”, has just named two functions. Extract the second job, name the extraction, and follow A2 Three-Tier Hoisting into the right module. The same logic scales: A4 Common Closure Principle is SRP at the package, and S2 Cyclomatic Caps is the linter that opens the conversation when judgement falters. Cut the debt as it appears, not when it accretes.

Copy a note and link

Grab this short comment and drop it into a PR comment or an LLM chat to prompt the right change.

Every method or function should do one thing only. Separate concerns out to make everything else easier.

/tenet/single-responsibility-principle/F1
Copy for paste
§0c

AI eyes only

Rule: one function, one verb. One reason to change per unit.

Reject: function or method names containing “and” or “then”. Reject: a handler that parses, validates, persists, and formats a response in one body.

Generate: separate functions for input validation, business transformation, persistence, and response shaping. Each takes typed input and returns typed output. Each is independently testable.

Diagnostic: if the function needs “and then” to describe, extract until each step has a name. Length is not the constraint. Count of reasons-to-change is.

§0d

Why?

  • Easier to name. A function that does one thing can be named for that thing. A function that bundles several jobs gets named for one of them. The rest are invisible from the signature. See F2 Intention-Revealing Names.
  • Easier to test and to change. A single-purpose function has a small surface, so test setup stays small, edits stay contained, and there are fewer ways to break what was not changed.
  • PR reviews are faster because the code is easier to read. One thread of logic per function scans quicker than mixed concerns tangled in one body.
  • The right home becomes visible. Once a unit is abstracted to a single responsibility, it is obvious whether it belongs in the local module, the product folder, or the generic folder. Pull the date formatting out of the invoice renderer and what is left is a formatter. It belongs where the other formatters live. Buried inside a multi-purpose function, the same logic stays where it does not belong. See A2 Three-Tier Hoisting.
  • Existing code surfaces. When a function is lifted to where it belongs, an equivalent function may already exist there: the existing version is reused instead of duplicated. See F3 Don't Repeat Yourself.
  • Smaller diffs. A change to a single-purpose function affects only that function. A change to a function with mixed concerns ripples across the file.
  • Easier onboarding. A single-purpose function explains itself from its name and signature. A multi-purpose function needs documentation that often does not exist.
The receipts
Origins, quoted passages, evidence, the strongest counter-argument and the reply.
§1

Origins

Robert C. Martin named the Single Responsibility Principle in his 1990s Principles of OOD writing and codified it in Agile Software Development: Principles, Patterns, and Practices (2002). Clean Architecture (2017) gives the sharper formulation. It beats “do one thing”: a module should be responsible to one, and only one, actor. The reason a module changes is the actor whose interests it serves.1 The actor test can be run in review where “do one thing” cannot.

The idea is older. David L. Parnas's “On the Criteria to be Used in Decomposing Systems into Modules” (1972) does not use the phrase “single responsibility” but states the same cut: list the design decisions likely to change, then give each one a module that hides it.2 SRP is the same boundary with different vocabulary when the hidden decision is “who pays when this changes”, not only which data structure stays private.

Practitioners arrived at the same place independently. The Linux kernel coding style §6 states it directly: functions should do one thing and do it well.3 Steve McConnell's Code Complete (2004) links the habit to functional cohesion in routines, where unrelated work in a single routine is a common source of regression.4 Martin Fowler's Refactoring catalogues the operational techniques: extract what does not belong, rename until the comment is redundant.5

Eric Raymond's Rule of Modularity in The Art of Unix Programming states the same constraint at the system level: small components with simple interfaces.6 SOLID's ordering is pedagogical rather than architectural. Martin answered the “just write simple code” critique in 2020: the principles hold because software structure has not changed much since the 1990s, and simplicity still needs a discipline behind it.7 Prickles leads with SRP because every other Foundation depends on this boundary holding.

§2

Quotes

A module should be responsible to one, and only one, actor. The most pernicious violations of this principle come from accidentally entangling two actors' concerns in the same code.

Robert C. Martin · Clean Architecture (2017)

Functions should do one thing. They should do it well. They should do it only.

Robert C. Martin · Clean Code (2008), ch. 3

We propose instead that one begins with a list of difficult design decisions or design decisions which are likely to change. Each module is then designed to hide such a decision from the others.

David L. Parnas · On the Criteria… (1972)
§3

Evidence

15 external sources, ranked by author authority. The first five are the canon; expand to see the rest, including the qualifiers and the named opposers. Each links out to its primary source.

  1. 01
    Robert C. Martin · 2017
    One actor, one reason to change: the version you can defend in review instead of hand-waving ‘do one thing.’
  2. 02
    David L. Parnas · 1972
    Hide volatile design decisions behind module walls; SRP’s older, more formal cousin.
  3. 03
    Steve McConnell · 2004
    Treats single-purpose routines as the default for code people can still read years later.
  4. 04
    Eric S. Raymond · 2003
    Unix doctrine in one line: keep parts small and the wires between them boring.
  5. 05
    Martin Fowler · 2018
    Extract and rename when responsibilities tangle: the mechanical moves people run.
  1. 06
    Robert C. Martin · 2008
    The famous triad (one thing, done well, done only) is quotable even if people skip the rest of the chapter.
  2. 07
    Linux kernel community · 1995 onwards
    Straight-up craft rule in a tree with brutal review: functions do one job and do it properly.
  3. 08
    Robert C. Martin · 2020
    Martin's answer to the just-write-simple-code critique: the principles hold because software structure has not changed, and simplicity needs a discipline behind it.
  4. 09
    Wikipedia contributors · 2024
    Straight summary of the acronym trail. Fine for orientation, thin for nuance.
  5. 10
    OpenJS Foundation · n.d.
    Line limits are a tripwire, not a substitute for asking who owns this code when it moves.
  6. 11
    OpenJS Foundation · n.d.
    McCabe-style caps catch functions with too many branches. Often a hint you merged several stories.
  7. 12
    SonarSource · n.d.
    Comes with length and cognitive-complexity gates: useful noise when a method is doing everyone’s errands.
  8. 13
    John Ousterhout · 2018
    Pushes thick modules with small surfaces. Warns that SRP is not an excuse to shard without a real API.
  9. 14
    Sandi Metz · 2016
    Duplication you can see is safer than the abstraction you guessed. Split after the second caller, not on vibes.
  10. 15
    Sam Hughes (qntm) · 2020
    Pushes back on treating Uncle Bob like scripture: a useful antidote when SRP becomes performance art.

Martin and McConnell talk craft; Parnas and Raymond talk structure. Fowler catalogues refactors and the Wikipedia entry maps the acronym trail. Linters enforce rough size and complexity caps, and Sandi Metzand the qntm essay warn what happens when the rule becomes a religion. None of that replaces the actor test in Clean Architecture1.

§4

Examples

Viewing: TypeScript.
Avoid

Before one function parses, validates, scales, and saves.

Filecounter.ts
function syncScaledCounter(raw: string): number {
  const row = JSON.parse(raw);
  if (row.n === undefined) {
    throw new Error("missing");
  }
  const scaled = row.n * 2;
  localStorage.setItem("counter", String(scaled));
  return scaled;
}
Prefer
Filecounter-handlers.ts
function getCounterOrThrow(row: { n?: number }): number {
  if (row.n === undefined) {
    throw new Error("missing");
  }
  return row.n;
}
function persistCounter(value: number): number {
  localStorage.setItem("counter", String(value));
  return value;
}
export const syncScaledCounter = (raw: string): number => persistCounter(getCounterOrThrow(JSON.parse(raw)) * 2);

Validate in one function, persist in another, compose them in a third: three verbs, three names, three tests. The enforcement tabs list how each language approximates the same mess with complexity and length rules. Those are proxies. Someone still has to say what the job is.

§4b

Enforcement

Viewing: TypeScript.

Apply these rules in eslint.config.mjs. The full enforcement across every tenet lives on the implementation page.

RuleToolCatches
max-lines-per-functionESLintfunctions that have grown past a single readable unit: the symptom SRP asks you to split.
complexityESLintcyclomatic complexity over threshold: too many independent paths in one body.
max-statementsESLinttoo many sequential statements in one function: often parallel concerns stacked.
max-paramsESLintargument lists long enough to signal a missing parameter object or a function wearing two hats.
max-depthESLintdeeply nested control flow: extraction usually reveals separate responsibilities.
unicorn/consistent-function-scopingeslint-plugin-unicornnested functions that capture nothing from the enclosing scope: move them to the outer scope, which often exposes a separate responsibility.
eslint.config.mjsconfiguration snippet
// Prickles-style flat config (excerpt): SRP proxies in eslint.config.mjs
{
  files: ['**/*.ts', '**/*.tsx'],
  rules: {
    'max-lines-per-function': ['error', { max: 15, skipBlankLines: true, skipComments: true }],
    'max-lines': ['error', { max: 150, skipBlankLines: true, skipComments: true }],
    complexity: ['error', 3],
    'max-depth': ['error', 3],
    'max-nested-callbacks': ['error', 3],
    'max-statements': ['error', 10],
    'max-params': ['error', 3],
    'unicorn/consistent-function-scoping': 'error',
  }
}
§4c

AI rules

File.cursor/rules/f1-single-responsibility-principle.mdc
---
alwaysApply: true
---

## Prickles F1: Single Responsibility Principle

One obvious job per function, class, or module. When a second concern shows up in the same unit, peel it out so each piece has its own reason to change.

Names should read as a single verb phrase. If you need “and” to describe what the function does, you probably have two responsibilities: extract until the sentence holds without a conjunction.

Say no to god procedures: parsing, validation, persistence, and response shaping live in different places unless one real task honestly spans them.

Treat max-lines, complexity, statement count, and parameter caps as linter smoke alarms, not definitions of SRP. They catch tangles early. They never replace asking who pays when this changes.

If a patch drops a whole feature into one long routine, bounce it until decomposition by verb is done and each slice has a name you can defend.

Repo layout, CI, and ESLint wiring for these paths live on /implementation, not repeated on every tenet.

§5

Counter-argument

Counter

The strong objection is familiar. Taken literally, SRP produces ravioli: walls of one-liners and names that parrot the type system, with a stack walk that needs a diagram. Sandi Metz pinned the price of the wrong abstraction: live with honest duplication before paying for a split that has not been earned.8 John Ousterhout's deep-module argument is the same worry from another angle: shallow types swap one source of confusion for another when the interface hides nothing.9

Both are fair. The wrong lesson is “responsibilities do not matter.” The right one is “pick the seam with care,” which is the whole point.

§6

Counter-argument retort

Reply

SRP was never “make everything tiny.” It was always “make each unit answer to one actor.” A function within the line cap with one reason to change stays. A function that schedules vet visits, totals donations, and emails volunteers because the ticket said “do the weigh-day handler” goes, however few lines it fits into.

When Sandi Metz warns against the wrong abstraction8, the argument is for evidence before extraction. That lines up with F3 and its second-occurrence trigger: see the echo, then cut. When Ousterhout asks for depth9, the call is for interfaces that swallow real complexity rather than a directory full of stubs. Both curb eager splitting. Neither is permission to weld unrelated concerns together because it was faster yesterday afternoon.

The day-to-day test is who signs off on the change. Two names means two jobs. Split until the name reads like a verb the reviewer recognises, let the linters nag about size, then merge. F5 Self-Documenting Code and F2 Intention-Revealing Names keep the seam obvious after the warnings go green.

§7

Notes

  1. [1]Robert C. Martin: Clean Architecture (2017): SRP as one actor / one reason to change, the formulation that replaces vague “do one thing.”
  2. [2]David L. Parnas: Communications of the ACM 15 (12), 1972: information hiding as the criterion for module boundaries.
  3. [3]Linux kernel community: Linux kernel coding style §6: functions should do one thing and do it well.
Disagree? Found a hole in the argument? Take issue with this tenet →
Last revised: 2026-10-13