3 ms·
I sort of agree with you. A better title/approach would have been "These aren't DRY, they're silly 'no common code' bigotry". I find the article resonates bec
by Ensorceled 6y ago
I sort of agree with you. A better title/approach would have been "These aren't DRY, they're silly 'no common code' bigotry". I find the article resonates because I've seen all of these anti-patterns defended with "because DRY". I agree, it's not DRY; but so many people get stuck on the "no code duplication" part. I'm not sure if the "This isn't DRY" is the best fight or "Sometimes DRY is not the best".
My favourite block of "DRY" code was a method that had a triple nested loop (for all object A, for all objects A.B, for all objects B.C) with a bunch of flags (like 15 different bools, ints, dates and arrays) that changed the ORM filters for A, for A->B, for B->C, and then changed what operations were done on A, B, C. Basically, at the end, the only similarity was the foreach part. The comment on the block of code had "Keep this loop together for DRY", as if they knew this was going wrong but not sure why. It ended up being 3 or 4 much simpler methods, based as you say, on requirements NOT code "shape".
- BeetleB 6y ago> I'm not sure if the "This isn't DRY" is the best fight or "Sometimes DRY is not the best". The problem is that when people believe this is DRY, they then tend to oppose the "real" DRY as well. Likely we'll have to give another name to the "real" DRY principle. In general, I've always felt that catchy names/acronyms are a bad idea for anything (e.g. free software, open source, pro-life/choice, etc). Almost all of them end up being used in ways that were differ from the original intent.
- Ensorceled 6y agoI guess I have to agree, in the example I gave, I actually had to fight with members of the team because they were sure the new multiple function approach (one for user, company and analytics) wasn't "DRY" in their eyes.