Skip to content

C++ Low-Level Design

Learn to turn a vague request into a C++ design you can explain, test, and change: which questions to ask, which classes to write and which not to, who owns each object, and how to tell whether the design still holds when the requirements move.

Every lesson on this site serves one skill: moving from a one-line request to a design you can justify. Here is that path in miniature, taken from the parking lot case study.

  1. The request. “Design a parking lot.” One line, deliberately vague.

  2. Ask the questions that change the design. “If the prices change while a car is parked, which price applies?” “The price shown at entry.” That single answer decides more of the design than any other.

  3. Write it down, numbered. FR-4: each ticket keeps the fee rule in force at entry. AC-4.2: tickets issued before a price change keep their rule. Now the design has something to be checked against.

  4. Decide what is not a class. A vehicle is an enum: nothing about it varies except which spots it fits. No Vehicle hierarchy, no Floor or Gate class, no Singleton.

  5. Give every member an owner. Each ticket holds std::shared_ptr<const FeeRule> rule_: shared with the car park, kept alive after a price change, and read-only: it points to a const rule whose functions are all const.

  6. Test it by requirement. A test named ac_4_1_and_ac_4_2_a_new_rule_applies_only_to_later_entries, and the code broken on purpose, eleven times, to check that the tests notice.

  7. Change it. Electric-vehicle chargers arrive. Spots gain a charger and tickets gain a charging price; the fee rules, payment, and exit do not change.

The learning roadmap describes three paths in detail. Pick the one closest to you; you can switch at any time.

Sections in reading order. Each card shows how many lessons are published so far and their difficulty; the site is written section by section, and a section marked “planned” has no lessons yet.

  1. Orientation

    What low-level design is, the five-step delivery framework, how to read the examples, and a reading path for your background.

    5 lessons · 5 beginner

  2. C++ foundations

    The C++ that design depends on: object lifetime, explicit ownership, RAII, smart pointers, interfaces, and value semantics.

    16 lessons · 9 beginner, 7 intermediate

  3. Modeling

    Finding classes, data members, and member functions; invariants, relationships, and lifecycles; outlines, traces, and state diagrams.

    12 lessons · 6 beginner, 6 intermediate

  4. Requirements

    Turning a vague request into clarifying questions, assumptions, use cases, acceptance criteria, and a traceable list.

    11 lessons · 6 beginner, 5 intermediate

  5. Design principles

    Cohesion, coupling, SOLID, DRY, KISS, and YAGNI, each with what it costs when it is pushed too far.

    14 lessons · 4 beginner, 10 intermediate

  6. Design patterns

    The classic patterns in modern C++: the problem first, the pattern second, and when a plain function or value type is better.

    35 lessons · 2 beginner, 27 intermediate, 6 advanced

  7. Architecture

    From classes to components: layers, ports and adapters, composition roots, repositories, and choosing among them.

    15 lessons · 11 intermediate, 4 advanced

  8. Advanced design

    Ownership graphs, thread safety, deadlocks, exception safety, idempotency, performance, and stable API boundaries.

    16 lessons · 16 advanced

  9. Testing and evolution

    Testing strategy, test doubles and seams, and changing a design safely, in small steps, as requirements move.

    7 lessons · 5 intermediate, 2 advanced

  10. Practice

    Quizzes, guided design walkthroughs, and a design-readiness checklist.

    11 lessons · 1 beginner, 8 intermediate, 2 advanced

  11. Case studies

    Complete designs, from a one-line request to tested C++, with the changes that follow and how to present them in an interview.

    19 lessons · 1 beginner, 11 intermediate, 7 advanced

  • The problem before the pattern. A pattern appears only after the simpler design has been shown and its limits are clear, with the costs and the cases where it does not fit.
  • Code you can trust, or code that says it is a sketch. Every C++ block is labelled. Code taken from the examples is compiled with GCC and Clang with warnings as errors, and its tests run, including under sanitizers; fragments are marked illustrative, and mistakes shown on purpose are marked flawed. See the about page for what each label means.
  • Diagrams with words. Every diagram has a written equivalent, so nothing depends on seeing it.
  • Exercises with answers. Most lessons end with an exercise; the answer stays hidden until you open it.
  • Search is in the header; the glossary defines every term marked in a lesson.
  • “Mark as read” and “Bookmark” buttons sit at the top of each lesson; My progress collects them. They are stored only in this browser.
  • The sidebars can be resized or collapsed, and the page text adjusts to the space.