Duplication over wrong abstraction

Build to explore
Jul 20, 2017 · 2 min read

We still remember we are thought from the first day about DRY(Don’t repeat yourself), at that time we didn’t know anything else. We consider it as a key principle but as the time passes, we start understand how wrong abstraction can make our life worse.

Many a times we come across a chunk of code which appears to be duplicate at that point but may not be later. In other words, the more specific it is the more usable it is, the more general it is the more constraints it has.

We go through this situation often, a person replaces a chunk of duplicate code with abstraction. After a few days, a new developer comes up with a new requirement, tries to use the same abstraction. He starts modifying as per his requirements. Later what happens?

Our own code appears to be a worst nightmare.

This was a single instance where,

‘Duplication is far cheaper than the wrong abstraction’ by Sandi Metz

Simple code is easy to maintain, but as the code gets bigger and complex with to many checks it becomes very complex to understand, waste of time.

Moral, it is better to introduce duplication instead of wrong abstraction, which will save time and cost. So whenever an abstraction becomes too complex and starts heading in a wrong direction it is better to use duplication.

)
Build to explore
Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade