Re:Software engineering topics I changed my mind on
by hydroxonium on Saturday January 23, 2021 @10:38PM
(#25888931)
"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.
Re:Software engineering topics I changed my mind on
by Rapzid on Saturday January 23, 2021 @09:29PM
(#25888444)
> 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.
Re:Software engineering topics I changed my mind on
by etxm on Saturday January 23, 2021 @10:22PM
(#25888825)
I’ve always found DRY to only apply well to two things:
- business logic
- something that your extracting as a library
Re:Software engineering topics I changed my mind on
by potta_coffee on Saturday January 23, 2021 @11:11PM
(#25889140)
It 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.
Re:Software engineering topics I changed my mind on
by njharman on Sunday January 24, 2021 @02:14AM
(#25890027)
I 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.
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);