Prefer duplication over the wrong abstraction (2016)
Points and comments are a snapshot, not live.
Duplication costs less than a wrong abstraction; inline back to move forward.
Sandi Metz argues that duplication is cheaper than the wrong abstraction. She describes a pattern: a programmer extracts shared code, then conditionals and parameters are added for new requirements, making the code incomprehensible. She advises inlining the abstracted code back into each caller, deleting unused parts, and re-extracting abstractions based on current needs. This avoids the sunk cost fallacy.
What commenters are saying
Commenters largely agree with Metz's thesis, but warn against a binary reading. One camp notes that the right abstraction is far cheaper than duplication; the trick is knowing when an abstraction is wrong. Some blame framework churn (e.g., Next.js, GraphQL) for creating wrong abstractions. A subthread debates microservices: one commenter notes they often become distributed monoliths with serialization overhead.