Free through lesson 3

Intro to Design & Refactoring

From naming, splitting up functions, and early returns, through SOLID, dependency injection, ports and adapters, characterization tests, and ADRs. Across 30 lessons you'll get to the point where you can turn "working code" into "readable, easy-to-change code." Every lesson lines up a before and after in both Python and Java, and confirms with a test that the same input still returns the same answer.

about 2.5 hours in total (estimate)

Slides for this course (for classes and in-house training) →

Curriculum

The 30 lessons are split into 6 chapters. We recommend working through them in order starting from Chapter 1, but feel free to skim just the parts you're curious about. * The code was actually run against Python 3.14 with pytest 9, and Java 21. Lessons that only need the standard library let you run before and after right in the browser and compare them. Try the pytest and Java tests locally.

Chapter 1 — Start with Readability (lessons 1–5)

Fix the things that snag you the moment you read the code: names, function length, comments, and nesting depth. We finish by learning to spot magic numbers and duplication as "code smells," giving you a checklist of what to fix.

Chapter 2 — Organizing Functions and Data (lessons 6–10)

Rebuild the shape of your logic and data with function extraction, removing duplication, and parameter objects. We finish by separating side effects from queries and updates, arriving at functions that are easy to test.

Chapter 3 — Principles of Object-Oriented Design (lessons 11–16)

Confirm each of the five principles — single responsibility, open/closed, Liskov substitution, interface segregation, and dependency inversion — one lesson at a time, each with a before and after. We finish by layering all five onto a single piece of code and seeing how the principles reinforce each other.

11

The Single Responsibility Principle (SRP)

Split Report, which changes for three reasons — aggregation, CSV export, notification — into one class per responsibility. SOLID's first principle: find responsibilities by who cares, and when.

about 5 min 🔒 Basic
12

The Open/Closed Principle (OCP)

Replace area, which grows another elif every time a new shape appears, with classes that each have their own area(). A design where a new type means just adding a class, never touching existing code.

about 5 min 🔒 Basic
13

The Liskov Substitution Principle (LSP)

An example where inheriting "a square is a rectangle" means changing the width also changes the height. SOLID's third principle: inheritance follows behavioral contracts, not linguistic categories.

about 5 min 🔒 Basic
14

The Interface Segregation Principle (ISP)

Split a bloated interface that forces a print-only device to also implement scan and fax into Printer, Scanner, and Fax. SOLID's fourth principle: split interfaces by what each caller actually needs.

about 6 min 🔒 Basic
15

The Dependency Inversion Principle (DIP)

Invert order processing, which directly constructs a MySQL storage class internally, by introducing an abstract OrderRepository. Swap in a DB-free in-memory version for tests.

about 6 min 🔒 Basic
16

Combining SOLID

Chapter 3 capstone: split notify — which mixes destination-specific ifs, message building, and sending — into parts using SOLID. Add a destination with a class; test with a fake Channel.

about 5 min 🔒 Basic

Chapter 4 — Cutting Dependencies (lessons 17–22)

Use dependency injection, ports and adapters, and layers to separate your core logic from the database, the clock, and the network. We finish with an exercise where you combine all of it to build a mini app yourself.

17

Dependency Injection (Passing In the Clock from Outside)

Rework a greeting function that calls datetime.now() internally so it takes a Clock from outside instead. Pass a fixed clock in tests to confirm the exact 6 p.m. boundary without waiting for it.

about 5 min 🔒 Basic
18

Ports and Adapters (Protecting the Core Rules from the Outside)

Split buy, which mixes a global dictionary and print directly into the business rule for deducting inventory, into a core, a port, and an adapter. Unit-test the core using only a fake adapter.

about 5 min 🔒 Basic
19

How to Split Layers (Entity, Use Case, Gateway)

Split register — which handles validation, business rules, and persistence at once — into entity, use case, and gateway layers. Dependencies point inward; add layers only when needed.

about 5 min 🔒 Basic
20

Testable Design (Creating a Seam)

Rework a lottery draw that calls random() internally so a number-returning function can be injected instead. Keep real randomness as default; test the boundaries at 5/6 and 30/31.

about 6 min 🔒 Basic
21

Avoiding Global State

Enclose a global counter, whose value depends on test order, inside an IdGenerator instance. Making state reachable only by whoever holds it, so you no longer need a cleanup reset().

about 5 min 🔒 Basic
22

[Project] A Mini App with Dependencies Cut

Rebuild a TODO app — which holds storage, ID generation, and listing in globals — by splitting it into entity, use case, and gateway. A capstone layering lessons 17-21's principles onto one app.

about 5 min 🔒 Basic

Chapter 5 — Letting Tests Protect You (lessons 23–27)

Learn to capture how untested code behaves right now, find seams to work through, and safely refactor in small steps. We finish with an exercise where you rebuild a legacy function while tests keep you safe.

Chapter 6 — Keeping It Up as a Team (lessons 28–30)

Turn good design from one person's effort into a team habit with a code review lens, making technical debt visible, and recording design decisions (ADRs). We close out all 30 lessons by linking an ADR back to the code it describes.

Once you finish all 30 lessons, move on to the Intro to Systems Development course, which puts design decisions into your development process, or the Intro to Agile Scrum course, which brings review and retrospectives into your team's rhythm. If you want to go deeper on writing tests, there's also the Intro to Testing Techniques course. All courses unlock with a membership.