I have found that early/premature abstraction generally has the opposite of the intended effect. Rather than making the system open to extension and flexible, it pours code concrete around the concrete classes and the interfaces. Invariably, the interface ends up with every public method of the only implementing class. And methods taking "SuperInterface" which only use a subinterface of that interface can't be untangled without a ton of effort.
Meanwhile, if you can figure out small reasonable interfaces with potentially multiple implementers, then all the sudden things get a lot easier to deal with.
Re:Beware of the Turing tar-pit (2004)
by a_wild_dandan on Sunday May 05, 2024 @07:22PM
(#40269536)
And they're expensive. You pay thrice:
1. Engineering the generalized solution, then
2. Carrying the cognitive burden of this new indirection layer, and finally
3. Ripping out this premature -- and so likely wrong -- abstraction
Premature abstractions are like alcohol: fun borrowed from the future, and paid back later with interest. If unavoidable, choose the abstraction most narrowly scoped to your actual code base, not a future one. Humans suck at prediction. Ask me how I know.
I like the comparison with alcohol, and on a tangent from that... I wonder if the 'Ballmer Peak' is partly explicable by being just drunk enough to avoid this kind of abstraction procrastination.
Unused abstraction makes reasoning about the codebase harder.