3 ms·
> DRY is about avoiding a specific problem, not an end goal unto itself. To add on to that, I think the key behind DRY is to not repeat a concept within your c
by DDSDev 6y ago
> DRY is about avoiding a specific problem, not an end goal unto itself.
To add on to that, I think the key behind DRY is to not repeat a concept within your codebase, and not failing into the trap of avoiding similar but slightly different code blocks that aren't exactly logically equivalent by carving up your code into nonsense. The former leads to elegant abstraction, while the latter just leads to functions with signatures like my_function(data, BITFIELD, opt1=false, opt2=true, opt3=false, BITFIELD);
- Rapzid 6y ago> To add on to that, I think the key behind DRY is to not repeat a concept within your codebase, and not failing into the trap of avoiding similar but slightly different code blocks that aren't exactly logically equivalent by carving up your code into nonsense. Dry is about not repeating behavior. It's not about not repeating text.
- etxm 6y agoI’ve always found DRY to only apply well to two things: - business logic - something that your extracting as a library
- hydroxonium 6y ago"Single source of truth" is more meaningful than the overly simplistic "DRY". If two things are _supposed_ to behave similarly, then not having duplicate code makes perfect sense. If two things just _happen_ to behave similarly (at first), it may be a hasty generalisation to immediately refactor them to use the same code.
- potta_coffee 6y agoIt requires subtle thinking. Instead what I see a lot of the time is the "rule" of DRY applied with religious fervor, and it produces the kind of code I enjoy working with the least.
- njharman 6y agoI tend to think of it in terms of bugs or less so, feature addition. Weighted by likelihood of bug. If there is bug, will someone have to fix it in one place. Or, remember it’s in 7 places. If later I DRY.