3 ms·
I fully agree with you. You mentioned that sometimes applying the DRY principle is a bad thing. Really, people often adhere to the DRY principle far too dogmati
by vlzdr 3y ago
I fully agree with you. You mentioned that sometimes applying the DRY principle is a bad thing. Really, people often adhere to the DRY principle far too dogmatically.
It’s better to have some duplication than to end up with a wrong abstraction.
I like the AHA principle much more. It suggests:
- Avoid Hasty Abstractions
- Prefer duplication over the wrong abstraction because duplication is far cheaper than the wrong abstraction
I found it here: https://kentcdodds.com/blog/aha-programming https://kentcdodds.com/blog/aha-programming.
The point about duplication being better than wrong abstraction is made here: https://sandimetz.com/blog/2016/1/20/the-wrong-abstraction https://sandimetz.com/blog/2016/1/20/the-wrong-abstraction.
And the principle doesn’t suggest avoiding abstractions altogether. It’s really only about avoiding the hasty ones. Wait with the abstraction until you feel it’s necessary or when duplication itself becomes a problem. At that point, you’ll have a clearer understanding of how the abstraction should function.
- rightbyte 3y ago> people often adhere to the DRY principle far too dogmatically This is a problem with all rule of thumbs for programmers. It is like we as a group are far more dogmatic than normal. Or our rules are worse. Or both. Dunno.
- ughitsaaron 3y agoI really liked the way Sussman discussed repetition in the SICP lectures. Something like, “If you find yourself repeating the something, that’s often a hint that there could be a useful abstraction.” It’s a far less prescriptive (and more appropriately flexible) way of expressing the same general idea than DRY.