|
|
|
|
|
by jchook
2039 days ago
|
|
It seems, early on, software devs mis-learn the meaning of “DRY” to mean “abstract away all repetition”. It takes experience to unlearn this bad habit and realize that “duplication is cheaper than the wrong abstraction”[1]. While this post may not provide a perfect example I think it gestures in the general direction of this very important principle. 1. https://sandimetz.com/blog/2016/1/20/the-wrong-abstraction |
|
On the other hand, DRY as a principle shines when it allows logical changes to a program to only require physical changes to the code in one place. E.g., in <horrible but self-contained algorithm> it's plausible that bugs might exist, and you'd really like bug fixes to apply to all implementations. The easiest way to manage that is to only have a single implementation. Likewise, to the extent that they're sometimes necessary your magic strings should be given a name so that your compiler can catch minor typos (supposing the edit distance between various names in your program is largeish).