3 ms·
Yeah, I've had this discussion with a lot of developers over the years with regards to DRY as well. I've seen people refactor code to fix "DRY" problems and the
by jsight 8y ago
Yeah, I've had this discussion with a lot of developers over the years with regards to DRY as well. I've seen people refactor code to fix "DRY" problems and the code ended up increasing in size due to the "deduplication" and increasing in complexity. When asked, "well do not repeat yourself isn't about reducing LoC".
That is technically correct, but is it then about increasing code size and complexity? Sometimes
- barbs 8y agoYes, exactly! I think people follow the principle blindly and try and pull out code that happens to be the same in two places. But if you anticipate that they might change in the future it's sort of a meaningless abstraction that doesn't give much benefit and just complicates the code. I think it's important to realise that these principles are good in general, but you can have too much of a good thing, and there are trade-offs involved as you take them more and more to the extreme. I can't say I'm an expert so I may be wrong about this, but it seems like you really need to get a sense of what's needed in each scenario - how should this bit of code work and is this communicated effectively? I find this takes practise to gain a "feel" for, but then that feels less teachable than simple principles.