Skip to main content

Sign in to CleanKata

Track your progress, earn XP, and unlock every lesson.

By signing in you agree to our Terms of Use and Privacy Policy.

Clean Code60 XP6 min

Successive Refinement

Start with working code, then refactor iteratively — never write clean code in one pass.

Bad Code Happens Fast, Good Code Takes Passes

The first pass is to make it work. The second is to make it understandable. The third is to make it maintainable. Professional programmers know this and plan for it — they do not expect to write clean code in one shot.

The TDD Cycle as Refinement

Red → Green → Refactor is successive refinement formalized. Never skip the refactor step — that's where clean code is born. Each iteration leaves the code slightly clearer, slightly better structured, slightly easier to change.

Code Challenge

Compare the one-shot attempt with the two-pass version.

💡Key takeaway

Working code is a starting point, not a destination. Budget time to refine.

🔧 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: Make it work, make it right, make it fast — in that order. Skipping 'make it work' leads to paralysis.

✗ Your version

Successive Refinement — CleanKata — CleanKata