by pech0rin · 4y ago · 0 comments
EVERYTHING HAS TRADEOFFS. Every single thing has tradeoffs. Obviously you should not write terrible, brittle code. The reason DRY is important is because when you start duplicating code, having 30 different serialization methods littered throughout your code, 5 different ways of calculating the same value, etc etc you see why it really matters. Its a GUIDELINE used to as a general rule. And as guidelines and general rules go -- its useful for juniors and people who don't have the experience to see the best way to write the code.
Its a good default, and like YAGNI, and 100 other programmer acronyms it has its ups and downs. Your pizza example is not "coincidental repetition" -- it is actual repetition -- you just abstracted it in a really poor way to make a strawman.
The problem is that he made his case poorly and I definitely don't agree.
The article gets this wrong by considering DRY as some kind of dogma and then discovering some situations where it doesn't work well. And then of course some commenters here get it wrong by only looking at situations were it does work well. It's the same religious discussion again as FP vs OOP, static vs dynamic typing, no code vs full code etc. etc. The real answer to each of these is always 'it depends'.
How great dev life could be if everyone saw it like that.
This should be the lede, IMHO.
Not enough people are flagging the post.
Bullshit. What's the tradeoff on using `gets` vs any other function?
Nothing. Absolutely nothing. `gets` is wrong 100% of the time period.
If you're wrong its not a trade and a lot of things in this article and about dry is wrong