the wrong abstraction

Sandi Metz has a great short article called The Wrong Abstraction. As software developers, we spend a lot of our time and effort on abstractions. All of us understand what it is like to run up against a bad abstraction that just doesn't seem to fit the problem. The interesting angle that Sandi takes is to prefer duplication over the wrong abstraction, due to the disproportionate cost of bad abstractions. This is an interesting idea that makes for an approach that only adds abstractions once they are needed and obvious, or when the code becomes too repetitive. To untangle an existing abstraction, simply locate the places the abstraction is used and copy/paste the abstraction inline. This provides the benefit of immediately removing the dependency while providing the ability to more readily identify and define a better abstraction.

All in all, this post is based on a simple idea, but it is a slight shift in the way to approach problems that most of us are taught. Instead of focusing on the existing abstraction and fitting the problem to it, focus on removing bad/unneeded abstractions and only add them where they truly provide value.