The 4 Rules of Simple Design
Kent Beck's four rules, in priority order, for a design that is always ready to evolve.
The Rules in Priority Order
Rule 1 (highest priority): Passes all tests — working software is the foundation. Rule 2: No duplication (DRY) — every piece of knowledge has one authoritative representation. Rule 3: Expresses intent — names, small functions, and clear structure so any reader understands the purpose without a comment. Rule 4 (lowest priority): Fewest elements (YAGNI) — don't add classes, methods, or abstractions speculatively. When rules conflict, higher rules win.
Constant Refactoring
Simple design is not a one-time upfront decision — it's the result of continuous refactoring guided by these four rules. After every change, ask: do all tests pass? Is there duplication? Is the intent clear? Is there dead weight? The four rules tell you when to stop adding features and start cleaning.
Code Challenge
Apply Rules 2, 3, and 4 to eliminate duplication, clarify intent, and remove speculative code.
💡Key takeaway
Kent Beck's four rules give you a stopping condition: when your code passes all tests, has no duplication, expresses intent, and has the fewest possible elements — stop and ship.
🔧 Some exercises may still have errors. If something seems wrong, use the Feedback button (bottom-right of the page) to report it — it helps us fix it fast.
Hint: Apply the rules in order: fix duplication first (Rule 2), then rename for clarity (Rule 3), then delete unused methods (Rule 4).
✗ Your version