jargon

Comparison

Premature abstractionvsSpeculative generality

Premature abstraction

there is an interface with one implementation and a config flag that has never been anything but its default.

Building a general mechanism before there is a second case to generalise from, so the abstraction encodes a guess about which axis will vary. It is worse than duplication because the wrong abstraction is harder to undo — every caller now depends on its shape, so removing it is a change to all of them. Sandi Metz's formulation is the one to remember: prefer duplication over the wrong abstraction.

Full entry →

Speculative generality

there is an interface, a factory and a strategy, and exactly one implementation of each.

Structure built for requirements that were imagined rather than observed. It is YAGNI's visible residue in the codebase: hooks with no callers, configuration with one value, a generic type parameter that is always the same type. Every piece of it is a thing the next reader must understand and cannot delete without proving nobody uses it, which is why it survives long after the imagined requirement is forgotten.

Full entry →

Related comparisons