4 ms·
I've heard of WET before, but I don't think that's the best "anti-DRY" phrase. In the unit-testing world, they say "DAMP, not DRY". Descriptive and Meaningful
by dragontamer 6y ago
I've heard of WET before, but I don't think that's the best "anti-DRY" phrase.
In the unit-testing world, they say "DAMP, not DRY". Descriptive and Meaningful Phrases, which happens to be repeating things a lot more than twice!
Some things are just clearer when repeated. Under such conditions, repeat yourself all the time (as long as it is clearer).
The question of DAMP vs DRY is eternal. Repetition is sometimes more clear, but sometimes is overly verbose and unclear. Its hard to know without experience.
- colechristensen 6y agoWhen I have encountered DRY in the wild, it has always been DRY zealotry. Repeated code was absolutely never allowed, and everything had to be modularized such that if anyone could ever imagine a future where something might get used again, it needed to be structured like that from the first merge. What it led to was an inscrutable codebase where unless you had been working with it for years, finding out where a thing was actually done was an exercise not unlike an archaeological dig. Like most things, it’s a matter of something which is a good idea, but the reasons it is a good idea are lost in its most common application which is at the exteme.
- tartoran 6y agoIt's a fairly common thing in our industry to take ideas to extremes where the initial benefit becomes a liability. Then comes the next thing and the same zealotry kills the next thing as well. The next thing is very welcome because it allows people to start as a blank slate and escape the corners they painted themselves in.
- potta_coffee 6y agoI think one key problem is whey people attempt to DRY the code before actually understanding what they're building. I like to let the code "tell me what to do"; I'm building something, and I repeat the pattern a few times, so I keep an eye on it. Eventually, I'll have a few repeated patterns I can look at. A lot of times, they're similar, but not the same. Waiting gives me the opportunity to review several similar patterns and find a more elegant solution that can accommodate all of the use cases, rather than forcing a sub-optimal abstraction for the sake of being DRY alone.
- Uehreka 6y agoThere are definitely times where the DRY vs DAMP question is a tough one, but I’ve also had lots of discussions where the DRY argument basically adds up to “not knowing ‘Find/Replace in Project’ exists”. Man, if I had a nickel for each time this has happened: I’m discussing a refactor with a DRY engineer, and they say something like “So what do you suggest? Just replacing that name in - every - single - place - it’s used? That would be error prone and time consuming.” Then I run a find/replace, the unit tests run, the green light flashes, heads explode. Again: DRY vs DAMP is often a very good thing to be debating, but in my personal experience the DRY advocates have gotten way too dogmatic.
- Lammy 6y agoI tend to think of it as "YAGNI, KISS, DRY" in that order à la "Reduce, Reuse, Recycle"
- sooheon 6y agoNice. Love this because principles should always be judged in relation to other principles. "DRY is good/bad" gets you going in circles, but "DRY but prioritize KISS" is a lot more practical.
- tartoran 6y agoRepetition also makes it harder to replace one thing in all instances but I agree that too much DRY can make a codebase a headache to wrap your head around: lots of different overloads for constructors and lots of branching inside the common code makes it hard and unpleasant to work with or ramp up as a new hire.
- xwdv 6y agoWhat about MOIST code?
- chrisweekly 6y agoI prefer AHA (Avoid Hasty Abstractions) as the counter to DRY.