DEV Community

loading...

Discussion on: We Should All Be Writing WET Code

Collapse
lifelongthinker profile image
Sebastian

I have seen this issue come up so many times, it kind of never gets old.

I believe DRY and WET are not at odds with one another. They complement each other.

In any system of a reasonable size there will be some degree of repetition. If we do not want any repetition, we would have to use an unreasonable amount of abstraction.

As with everything in our field, DRY and WET are rules of thumb that can help inexperienced developers get up to speed, but should never be taken as absolute rules without exceptions. You as the developer are responsible to see the big picture and act accordingly (DRY and WET alone are only ever parts of the truth, they can never give the full picture).

Generally, repetition is problematic and should be avoided. But not at all costs. If your alternative costs you more than the repetition itself, you are better off without it.

Indeed, WET can help fight too early and too complex abstractions. But then there is always the danger of someone not realizing they are doing the THIRD repetition or (even worse) not caring. And very quickly you find yourself with too much repetition.

On the other hand, any abstraction only goes so far. At some point any system has to be (partly) substituted to remain maintainable. This, I believe, is one of the core problems in our field.

By only adding code to an existing code base (without removing any, restructuring, refactoring) you will quickly end up in a maintenance hell with lots of flags, parameters and hard-to-reason-about workarounds.

Forem Open with the Forem app