Skip to content

The Drought

The DRY principle (“Don’t Repeat Yourself”) has long been accepted as a fundamental principle of software development.

It’s wrong. Or at least frequently misunderstood.

I mean, in general the principle is sound. Don’t copy/paste code multiple times. Centralize logic or functions together in services. But, the dogma that goes with the principle is a major driver of spaghetti code. “Hey, this function is similar to that one, can we share that logic?” – this sort of code review comment results in methods that take boolean parameters that are applied internally (public void foo(boolean isInSomeRandomMode) that make zero sense from an API or business perspective, but are accepted because “it is bad to duplicate code, no matter what.”

I’m going to submit that the maintenance costs of this approach far exceed any perceived benefit. DRY should be applied at the service/architecture level, not low level code. If some bits of logic are duplicated, fine. Maybe even good.

What dogmatic software development rules do you think are wrong?