jargon

Comparison

Copy-paste programmingvsPremature abstraction

Copy-paste programming

the bug was fixed in one of the four near-identical blocks, and reported again a month later from the other three.

Producing new code by duplicating existing code and editing it, so a defect or a rule change exists in several places. The duplication is not itself the sin — a little duplication is cheaper than a bad abstraction — the sin is duplication of a decision, which then has to be changed everywhere consistently. The tell is that the copies drift, and nobody knows which of them is the correct one.

Full entry →

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 →

Related comparisons