Clean Code

Code other people can read and change.

Writing code that other people (and your future self) can read, trust and change: why readability pays, naming, functions and comments, formatting and style, simplicity, duplication and the wrong abstraction, complexity, cohesion and coupling, SOLID and its critics, composition, boundaries and dependencies, error handling, null and absence, types as documentation, code smells, refactoring, technical debt, static analysis, reviewing AI-written code, and team conventions. Language-neutral, with examples in JavaScript, Python, Java and Go, and a fair hearing for competing schools of thought rather than one book's rules. By the end you can spot what makes code hard to change and improve it in small, safe steps.

7
chapters
22
modules
~8h
of learning
22
live now
22 modules

Take modules in any order. The route suggests one that builds up naturally.

Take a look inside

The big picture, before the details

What makes code easy to read and change: readable foundations, simplicity, design, errors and edges, changing code safely, and team habits. Watch the tour, or click any part.

namesshapedesignerrorschangeteamsread · understand · change safelycode is read far more often than it is written

Readable foundations: names that explain, functions that do one job, comments that say why (modules 1–4).

A taste of module 8: flatten a nested function in three behaviour-preserving steps and watch its complexity fall.

function canRefund(order, user) {
  if (order) {
    if (order.status === "PAID") {
      if (user.isAdmin || user.id === order.customerId) {
        if (daysSince(order.paidAt) <= 7) {
          return true;
        } else {
          return false;
        }
      } else {
        return false;
      }
    } else {
      return false;
    }
  } else {
    return false;
  }
}
Cognitive complexity15
Deepest nesting4

Same behaviour at every step.

01

Foundations

Readable code, from names to functions.

4 modules · 85 min

02

Shape and simplicity

Consistent shape, and as little as possible.

4 modules · 90 min

03

Design

How pieces fit together.

4 modules · 95 min

04

Errors and edges

Making failure and absence explicit.

3 modules · 70 min

05

Changing code

Smells, refactoring and debt.

3 modules · 65 min

06

Tools and teams

Keeping a whole codebase clean.

3 modules · 60 min

07

Capstone

Put it all together.

1 module · 35 min