Skip to main content
Clean Code 60 XP · 6 min

The 4 Rules of Simple Design

Kent Beck's four rules, in priority order, for a design that is always ready to evolve.

Showing
Ad (728×90)

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.

Done with this lesson?

Mark it complete to earn XP and track your progress.