4 ms·
"Every piece of knowledge must have a single, unambiguous, authoritative representation within a system". What piece of knowledge does your add1 function repre
by dllthomas 3y ago
"Every piece of knowledge must have a single, unambiguous, authoritative representation within a system".
What piece of knowledge does your add1 function represent? I don't think you're strawman is actually DRY (which is a problem - damp strawmen can mildew).
I do agree that there are sometimes tradeoffs that can make a less DRY approach a better one, but not all deduplication is "DRY".
- hannasanarion 3y agoA critical word here is "knowledge". Every element of data, core capability, or logical object should have a single authoritative source. Having multiple db connections or ui controllers would, in fact, be a horrible nightmare, obviously. But not all code is knowledge, some of it's just boring work that does something to some local stuff and it doesn't necessarily need to be sharable with other parts of the code base, just because the logic looks kinda similar.
- dllthomas 3y agoRight. My quote was the original formulation of DRY as a principle, from The Pragmatic Programmer, and I think it's a good principle. The common (mis?)understanding of DRY as primarily syntactic both overshoots and undershoots. As many here have discussed, it can lead to combining things you shouldn't (I jokingly call this "Huffman coding"), but it can also fail to recommend combining knowledge when it is represented differently. If I'm saying "there is a button here" in my HTML and in my CSS and in my JS, that's three places for that piece of knowledge even if those three places don't look anything alike. Changing the CSS to "here is what my buttons look like" and the JS to "here is how my buttons behave" would be DRYer.