DRY can be expensive
Don't repeat yourself! Except when doing so might be harmful...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…
- It breaks the flow of the code
- It adds new dependencies to manage
- Too many abstractions can be hard to follow
- The wrong abstraction is used (often caused by premature optimization)