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

Discussion on: Stop Writing DRY Code

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.