2 ms·
The problem is with being either dogmatic or thoughtless in either direction. I've seen what you're talking about: people combine code religiously because of DR
by lolinder 3y ago
The problem is with being either dogmatic or thoughtless in either direction. I've seen what you're talking about: people combine code religiously because of DRY, leading to insane pyramids of abstractions that are impossible to modify.
However, I've also seen people copy and paste everything they ever need. When that happens, those offshoots gradually evolve independently from one another, and introducing a proper abstraction becomes a huge slog. I've spent hours reading through git blame trying to piece together a phylogenetic tree of the various copies of the same code so we can ensure that the new abstraction contains all relevant features and bug fixes. I wish those developers had thought more carefully about DRY.
I think the best balance is to use these catch phrases as principles to guide your decision making, while being willing to make exceptions when they don't apply. If DRY makes you think for a second before copying a piece of code, it's done its job, even if you decide that this situation really does call for a copy.