We're taught that duplication is the enemy.
It isn't the worst thing.
The wrong abstraction is.
Two copies of a function
are honest about being two things.
You can change one
without breaking the other.
A premature abstraction
pretends they're the same thing
before you know that they are.
Then the cases diverge,
and you start adding flags.
if type == 'a'. if legacy.
The parameter list grows teeth.
Now every change is dangerous
because everything shares one body.
Wait. Let it repeat a few times.
The right shape shows up
once you've seen the real variations.
Duplication is cheap to fix.
The wrong abstraction you live with for years.
– Serguey Asael Shinder
Top comments (0)