DIGNALEGI

The reading room · Digna Legi

The Wrong Abstraction

A personal relevance score

80–100: high value. 70–79: worth the time. Below 70: below the usual publication threshold.

Evidence-reviewed score based on available publisher text. The provided text develops the mechanism and repair procedure but includes no detailed code case or comparative outcomes; its categorical claim about conditional paths exceeds the demonstrated support.

Scores reflect one reader’s profile, not an objective quality rating. Best is a separate personal selection.

How scoring works →

This brief · about 2 min with detail

Original article ↗

Why read this

Shared code can become harder to change than duplicated code when new requirements turn a common operation into a collection of exceptions.

AI brief · Checked against source text

The main idea

Sandi Metz argues that duplication is preferable to a mistaken abstraction: shared code that groups operations which no longer belong together. As requirements diverge, developers preserve that shared structure by adding parameters and conditional branches, making it harder to understand and change. Restoring separate implementations can expose what each caller actually needs, allowing better abstractions to emerge from current requirements.

Some background helpful. Basic familiarity with functions, callers, parameters, and conditional branches.

Go a little deeper

Past effort becomes design authority

Existing code carries an implicit claim that it is correct and necessary. Metz connects this authority to sunk costs: the more effort a complicated implementation appears to contain, the harder developers find it to discard. Complexity can therefore become its own protection, encouraging another patch precisely when reconsidering the structure would be more useful.

Separate first, then compare

The repair is specific: copy the shared implementation into every caller, use that caller’s parameter values to identify the paths it executes, and delete everything else. This removes branches as well as the shared wrapper. Comparing these smaller implementations can reveal that callers which appeared to share behavior were actually doing substantially different work.

Correctness has a lifespan

An abstraction need not have been a mistake when introduced. Later requirements can invalidate the commonality it once captured. This distinction makes replacement a response to learning rather than a verdict on the original programmer. After removing the old structure, developers can look again for genuine duplication without requiring the next design to preserve yesterday’s boundaries.

How the case is made

Metz builds the argument through a programmer-by-programmer scenario, questions prompted by audience reactions, and observations of teams revising difficult shared code.

Where the idea has limits

Metz allows that accumulating a few conditionals can help reveal the underlying pattern; the recommendation concerns abstractions whose shared structure has become misleading.

A question to take away · from Digna Legi

Which parts of a shared implementation would each caller retain if preserving the existing structure were no longer a requirement?

What the original adds

The original traces how successive programmers inherit and extend an abstraction, and describes the psychological pressure to preserve increasingly incomprehensible code.

Why return to this

Return to this when every new requirement adds another parameter or conditional to a shared abstraction. Metz traces how that design deteriorates and gives a concrete way to separate the callers again, so the actual commonality can become visible.

Programmers struggling to extend shared code.

The advice targets abstractions that no longer represent a coherent shared idea. It is not a blanket recommendation to retain all duplication or remove every conditional.

About this brief

AI-written, then separately checked for source support, useful detail and clarity. The author’s claims and our editorial question are kept separate. The original remains the author’s work. How we select and summarise →

Digna legi. Worth reading.