Clean code practice

Practice turning messy code into clean code.

Each problem is working code with a design problem. Refactor it, and the grader checks three things: the behaviour still works, your design takes a new requirement without a rewrite (the grader adds one, like a new courier), and the design rules pass.

Browse problems10 problems free after sign-up
if (courier.equals("DELHIVERY")) {
    ...
} else if (courier.equals("BLUEDART")) {
    ...
} else if (courier.equals("INDIA_POST")) {
return rules.get(courier).cost(order);

Five kinds of problem

L1Messy → Pattern

Working but messy code. Apply the right pattern or principle.

L2Wrong pattern → Fix

A pattern was applied and made things worse. Replace it.

L3Over-engineered → Simplify

Abstraction with no payoff. The fix is to remove it.

L4Capstone

Redesign a small system end to end, machine-coding style.

BUGBug report → Root cause

A support ticket. Fix the design flaw, not just the symptom.