DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Discussion on: Stop Writing DRY Code

Collapse
 
etienneburdet profile image
Etienne Burdet

IΒ agree that sometimes, flat, repetitive code is easier to maintain. A good exemple is tests : kentcdodds.com/blog/avoid-nesting-...
They are linear an repetitive by nature and trying to factor them too much will cause more headaches than anything when having them to evolve.

Part of CSS is like that, some constants or just things that "happen to be alike" but won't necessary exactly the same all the time.

Collapse
 
peerreynders profile image
peerreynders

A good example is tests

Tests have different priorities - Tests Too DRY? Make Them DAMP!:

"Since tests don't have tests, it should be easy for humans to manually inspect them for correctness, even at the expense of greater code duplication. …which emphasizes readability over uniqueness"

and yet

"the DRY principle is still relevant in tests; for example, using a helper function for creating value objects can increase clarity by removing redundant details from the test body."

The challenge is to keep inappropriate coupling (resulting from overzealous DRY) out of tests because that can lead to fragile tests.