Skip to main content


DRY (Don't Repeat Yourself) is a good principle to make software more maintainable. It can also help code to be more readable and efficient. But it can also lead extra layers of abstraction and separation from the actual logic. Pure DRY should therefore never be the absolute goal.

Sometimes a little repetition can make things less complex. Removing repetition usually means an extra layer of abstraction and every layer of abstraction can make the system exponentially more complex. Especially when the abstraction isn't hiding the complexity behind an interface. When you have to deal only with that interface it doesn't matter how many layers there are behind it. But when you have to manage all those layers it gets tedious really fast.

Often there is the golden middle ground. Trying to avoid repetition as much as possible should always be the aim. But sometimes it's ok to repeat yourself when it can prevent otherwise unnecessary abstraction.

Repeating something can also offer more flexibility. The more general solution that might remove complexity through repetition must be more complex to handle more different use cases. After all you can't remove the complexity, you can only move it around, or hide it behind interfaces.