Notes from Repeat Yourself by Matthias Endler. Another Endler post that says a quiet thing loudly — experts copy code all the time, and the rest of us feel guilty about it for no good reason.
What stuck
- Two modes of programming. Writing mode and refactoring mode are separate activities. In writing mode you get the idea down and silence the inner critic. In refactoring mode you play the critic. Mixing them kills momentum. He draws the same parallel to prose writing — draft first, edit second — which tracks with Anne Lamott's "shitty first drafts."
- The wrong abstraction is worse than duplication. Sandi Metz's line — "duplication is far cheaper than the wrong abstraction" — is the spine of the whole post. Once other code depends on a bad abstraction, removing it is expensive and politically awkward. Sunk cost kicks in.
- Wait for the pattern to reveal itself. Copy the code, resist the urge to abstract until the second or third copy. By then the actual shape of the shared logic is visible, not guessed at.
- Shared bugs vs. isolated bugs. A bug in a shared abstraction breaks every caller. A bug in a copy breaks one call site. The DRY assumption — "fix it once" — only holds when the bug is actually the same across all uses.
- Code that looks similar isn't necessarily the same. The shopping-cart vs. shipping-cost example is a clean illustration. Both loop and sum, but they diverge immediately once real requirements land.
What I'd connect
- This applies to agent-generated code too. When an agent writes code, it defaults to DRY because that's what the training data rewards. But an agent doesn't feel the momentum cost of pausing to abstract — it doesn't have flow state. The advice is even more useful for humans than for machines, and it's worth pushing back on agents that over-abstract early.
- The OODA loop reference is underrated. He buries it in a footnote, but "decide at the last responsible moment" is the real principle. DRY is a premature decision about which pieces of code are the same. Waiting costs almost nothing; committing early costs a lot.
What's missing
He doesn't say much about when duplication actually is the problem — the cases where you've copied the same validation logic into six handlers and a real bug slips through five of them. The post argues the other side well, but the heuristic for "okay, now abstract" is still just "when it feels tedious." That's honest, but vague.