4 ms·
Sometimes "A little copying is better than a little dependency."
by pkaye 7y ago
Sometimes "A little copying is better than a little dependency."
- ubu7737 7y agoSometimes a little copying is better than 3 levels of complexity to create 3 different types of object. It's fine to hone your craft as you work by making use of abstractions that make sense at a larger scale of using that abstraction. I forgive you. But at 3+ levels in the class hierarchy to accomplish that unification of 3 different types, I have to object strenuously that you are straining purpose.
- Quekid5 7y agoI absolutely subscribe to that, but then again, I don't have a Rule of Three or similar... It's a bit difficult to get across in text, but the minimum number of repetitions of a piece of code to make it "worth" putting it in a function is... 1. (According to me, and Tony van Eerd of Postmodern C++ fame. I had come to this conclusion on my own, but his talk really articulated it well.) It's all about limiting the scope of side-effects, accidental reuse or variables, etc. etc. such that a human can do chunking to understand the whole. I generally find that this is not an easy thing to capture in "metrics" or "rules". Guidelines with reasonable rationales, etc. etc. and when-not-to's, definitely, but that's a really hard thing to do and it doesn't get many clicks. EDIT: ... and just to get back to DRY. The acronym is far too absolutist, but Try-Not-To-Repeat-Yourself-Too-Much-Unless-You-Have-Good-Reason-To isn't quite as catchy, is it?
- wrmsr 7y agoI've seen so many times people going all in on DRY not understanding that just as dangerous as duplication is _coupling_ - the inevitable result being some ungodly $COMPANY_NAME_common lib with a thousand dependencies, and usually only depped in a codebase for a config parser and a string helper. See also node_modules and left-pad.io.