| ▲ | layer8 7 hours ago | ||||||||||||||||
DRY is misnamed. I prefer stating it as SPOT — Single Point Of Truth. Another way to state it is this: If, when one instance changes in the future, the other instance should change identically, then make it a single instance. That’s really the only DRY criterion. | |||||||||||||||||
| ▲ | xnorswap 7 hours ago | parent | next [-] | ||||||||||||||||
I like this a lot more, because it captures whether two things are necessarily the same or just happen to be currently the same. A common "failure" of DRY is coupling together two things that only happened to bear similarity while they were both new, and then being unable to pick them apart properly later. | |||||||||||||||||
| |||||||||||||||||
| ▲ | mosburger 6 hours ago | parent | prev | next [-] | ||||||||||||||||
I said this elsewhere in the comments, but I think there's sort of a fundamental tension that shows up sometimes between DRY and "a function/class should only do one thing." E.g., there might be two places in your code that do almost identical things, so there's a temptation to say "I know! I'll make a common function, I'll just need to add a flag/extra argument..." and if you keep doing that you end up with messy "DRY" functions with tons of conditional logic that tries to do too much. Yeah there are ways to avoid this and you need to strike balances, but sometimes you have to be careful and resist the temptation to DRY everything up 'cuz you might just make it brittler (pun intended). | |||||||||||||||||
| ▲ | gavmor 4 hours ago | parent | prev | next [-] | ||||||||||||||||
Yes, and there are many different kinds of truth, so when two arise together—we can call this connascence—we can categorize how these instances overlap: Connascence of Name, Connascence of Algorithm, etc. | |||||||||||||||||
| ▲ | Silamoth 6 hours ago | parent | prev | next [-] | ||||||||||||||||
That’s how I understand it as well. It’s not about an abstract ideal of duplication but about making your life easier and your software less buggy. If you have to manually change something in 5 different places, there’s a good chance you’ll forget one of those places at some point and introduce a bug. | |||||||||||||||||
| ▲ | mcv 7 hours ago | parent | prev | next [-] | ||||||||||||||||
That's how I understood it. If you add a new thing (constant, route, feature flag, property, DB table) and it immediately needs to be added in 4 different places (4 seems to be the standard in my current project) before you can use it, that's not DRY. | |||||||||||||||||
| |||||||||||||||||
| ▲ | pydry 7 hours ago | parent | prev [-] | ||||||||||||||||
Renaming it doesnt change the nature of the problem. There should often be two points of truth because having one would increase the coupling cost more than the benefits that would be derived from deduplication. | |||||||||||||||||