DRY can be expensive

November 12, 2021

If I’ve told you once, I’ve told you a thousand times: I never repeat myself.

And neither should you! Right? Don’t repeat yourself, or the DRY principle tells us this.

There are many ways to apply the DRY principle in IT systems. In code, it can be as simple as extracting a common behavior into a function that can be called from multiple places.

But when can DRY be harmful? Here are a few cases…

  1. It breaks the flow of the code
  2. It adds new dependencies to manage
  3. Too many abstractions can be hard to follow
  4. The wrong abstraction is used (often caused by premature optimization)

Related Content

Staying DRY in a WET codebase

Can we get the benefits of WET and DRY at the same time?

Is it a good day to optimize?

How do you decide between watching James Bond or a romantic comedy? Every decision optimizes for something. What do you optimize for when designing computing systems?

Better code review

How can we encourage less superficial code reviews?