Discussion on: Stop trying to be so DRY, instead Write Everything Twice (WET)

mahlongumbs profile image
Mahlon Gumbs

Articles like this really bother me. Anything that can be done, can be done poorly. That, by itself, is not a reason to avoid doing said thing.

Understanding how and when to create abstractions is not trivial. The end result may seem trivial at times but the skill is something learned and harnessed over time (sometimes over a career).

DRY, like most concepts in software, is more of a guideline rather than an unbreakable rule. Like all good guidelines, you violate them if you have good reason to do so and with a solid understanding (and acceptance) of the consequences.

An article suggesting replacing concept A with concept B because sometimes concept A is done incorrectly adds to the noise developers must learn to filter out as we hone our craft.

For example, it makes no sense to write something again if it is identical to the first. So telling someone to write everything twice is just as bad as misrepresenting what DRY is.

It is better to spend the necessary time it takes to understand your situation and apply the concepts that makes sense there than it is blindly start going against sound guidelines just because it may seem easier.

As an example, consider our old friend the RDBMS. A WET DB can lead to some pretty severe data issues. One would not break normalization on a whim. However, because of the needs of a data wharehouse, a fully DRY DB would be catastrophic; so denormalizing for this very specific use case makes sense. The consequences here a fully know and accepted.

^ RDBMS? Dude! Just use Mongo! :-)
I know. I know. But the point remains the same.

Understand your situation and apply the tools and concepts (and possible modifications to said tools and concepts where reason demands it) that best fits.

thecrius profile image
Claudio Vallesi

I can only agree with you.

Also, this WET concept is basically taking a guideline so simple "Do not write things twice, if you can" and suggest a more complex guideline "Write things twice, but not thrice!"

Really? how's that supposed to be easier to remember and follow?

As the old philosophers suggest, we should aspire to the best possible, not the average. Because we're flawed, we will never achieve the best possible but certainly we will achieve better result that whom who tries to achieve the average.

Oh, and the DIV example is horribly misleading. That is not an exception to DRY.