All laws

60Maintainability

DRY Principle

Every piece of knowledge has one authoritative representation.

If

Duplicated knowledge drifts, because nothing forces the copies to change together. The cost is not the extra characters — it is that some future editor fixes one copy and ships a system that now quietly contradicts itself.

Then

Deduplicate knowledge, not text. Before merging two similar blocks, ask whether they change for the same reason and at the request of the same person; if not, leave them apart.

Unless

Duplication Is Cheaper Than the Wrong Abstraction — two blocks that merely look alike today will fight each other the moment they need to diverge

Improve this article on GitHub