Skip to content

Design Patterns ​

Design patterns are the classic solutions to recurring design problems, distilled and handed down by the people who came before us. This volume covers the 21 core GoF patterns and re-implements every one of them with modern C++.

Instead of the traditional "definition + UML + example" lecture format, our approach is to start from the most intuitive, most primitive code and let each pattern emerge step by step — pinning down what problem it actually solves, why each evolutionary stage is still not enough, and what a safer, closer-to-zero-overhead version of the same pattern looks like once C++17/20 brings std::variant, concepts, CRTP, and templates to the table.

The companion compilable project lives in the repository at code/volumn_codes/vol4/design-patterns/; each pattern is an independent CMake sub-project, and cmake -S . -B build && cmake --build build is all it takes to run one.

Creational ​

Structural ​

Behavioral ​

Advanced: Generic and Template Patterns (Planned) ​

Beyond the classic GoF patterns, C++ has its own set of "template-level" design techniques. They are the extension direction of this volume, to be filled in later:

  • Policy-Based Design
  • Type erasure (the machinery underneath std::function)
  • CRTP (static polymorphism)
  • Mixins and composition-based design
  • Tag dispatching and if constexpr dispatch
  • NVI (Non-Virtual Interface)
  • Templates and DSL construction

pdf-latest-4-g85128cc · 85128cc · 2026-10-05