4 ms·
> In WET code (write everything twice) everything looks primitive, as if it was written by complete newbie, and every change needs to be added at multiple place
by ollien 2y ago
> In WET code (write everything twice) everything looks primitive, as if it was written by complete newbie, and every change needs to be added at multiple places, but each change is trivial and time to finish is predictable. I would go as far as calling the code boring. The most difficult thing is to resist the temptation to remove the duplicity.
This only scales so far. After some point, it's very easy to run into cases where you meant to change something everywhere but forgot/didn't know about others. Not to say everything should be so compartmentalized as to restrict change, but there is a balance to be had.
- thfuran 2y agoYes, what actually happens is that many code changes are released half-baked because logic only got updated in 1 (or 13) of the 14 places that needed to be updated, and the cussing and hair pulling just starts later.
- rrr_oh_man 2y agoTests, baby
- thfuran 2y agoTests don't really help you when a newly discovered bug affects logic copied in ten places and you're only aware of two of them. You can add a regression test to the places that you update, but not the others. And then if there's another bug discovered in the duplicated code, a different subset of the copies might get changed and have tests added. Suddenly it looks like these different versions of the repeated logic are intended to be behaving differently for some unknown reason even though the divergence is purely accidental.
- gary_0 2y agoWhich is why you need a balance between WET and DRY. DAMP = Don't Alter in Many Places.
- yakshaving_jgt 2y agoOr, use a sufficiently well designed type-checking compiler, like GHC.