the hidden cost of abstractions

nov 2024

that elegant abstraction you built is slowing down your team. on premature optimization, cognitive load, and keeping things simple.

the problem

you've seen it. someone builds a beautiful abstraction layer. it handles every edge case. it's generic, reusable, extensible. it's also completely overkill for what you actually need.

when abstractions help

good abstractions hide complexity that actually exists. databases abstract away disk I/O. HTTP libraries abstract away socket programming. these are good because the complexity is real and unavoidable.

when abstractions hurt

bad abstractions hide complexity they created. that 5-layer architecture for a CRUD app? that's not solving a problem—it's creating one.

the cognitive load tax

every abstraction has a cost:

three similar lines of code are better than one premature abstraction.

a better approach

rule of three: don't abstract until you've written the same code three times

delete ruthlessly: if an abstraction doesn't earn its keep, delete it

optimize for deletion: the best code is code you can delete easily