
DRY vs RUG — When Repeating Code Is Actually the Better Design
TL;DR DRY is great when duplication creates maintenance risk. Like duplicating a domain logic, like a discount. But sometimes repetition is the better design. A useful mental model is RUG — Repeat Until Good. Instead of prematurely extracting abstractions, allow small duplication until the design becomes obvious. Blindly chasing DRY can lead to: Fragile abstractions. Hidden intent. Tight coupling between unrelated parts of the system. Sometimes, explicit repetition makes the code clearer and more resilient. Read the Full Thing DRY — Don't Repeat Yourself — is one of the most widely taught principles in software engineering. And for good reason. When the same logic is duplicated in multiple places, changing behavior becomes risky. One fix may require updates across several locations, increasing the chance of bugs and inconsistencies. That’s where DRY shines. But there's a less discussed idea that appears in some engineering discussions: RUG — Repeat Until Good. It’s not a formally estab
Continue reading on Dev.to
Opens in a new tab

