4 ms·
> My favorite counter-acronym to DRY is WET: write everything twice (or thrice!). Doing and then redoing it once you understand it better is the best way to lea
by tcfhgj 3y ago
> My favorite counter-acronym to DRY is WET: write everything twice (or thrice!). Doing and then redoing it once you understand it better is the best way to learn how to apply DRY correctly.
I don't like it.
It's so much worse than DRY.
Imagine you have something that is duplicated. Instead of deduplicating it, you leave it.
Later at one location you make modifications, like rename a variable, introduce an optimization, whatever.
Now, if you don't explicitly remember, that duplication is hidden.
Months later you need to change or use the functionality somewhere else.
How likely is it you'll edit it just in one place or introduce another duplication?
Now let that run for a few years and you'll have this all over the code base.
Sounds nice
- dahart 3y agoSounds bad, the only problem is it’s a straw man imaginary scenario. Write everything twice isn’t a call to leave repeated code around at all, it’s a call to learn by doing rather than believe that dogmatic principles like DRY can get you there the first time. The idea behind WET is to use the right tool for the job, and acknowledging that you probably won’t know what the right tool is until after you’ve tried doing the job. DRY is the right tool for some jobs, but not all jobs. There are downsides to duplicating code, and there are downsides to merging code. I’ve seen examples of such downsides in both directions in practice. The main downside of DRY I was trying to point out in other comments is that multiple dependencies on code adds additional complexity and risk regardless of the quality of the abstraction. A lot of people here are arguing the quality of the abstraction is what matters, but that’s only sometimes true. And in the cases where eschewing DRY is called for, it often has nothing to do with the quality of the abstraction.
- tcfhgj 3y agoYour interpretation of wet has nothing to do with wet.