๐Ÿงฉ Design Patterns with C++
Home Chapters Examples Diagrams Bibliography GitHub โ†—
  1. Home
  2. Principles (SOLID, Martin)
Part 2 2 chapters

Principles (SOLID, Martin)

The five SOLID principles in modern C++ terms: SRP/OCP/LSP first, then ISP/DIP and dependency injection without a framework.

Chapter 3

SOLID I: single responsibility, open/closed, Liskov substitution

Splitting a billing engine along the lines of what changes: one responsibility per type under the Single Responsibility Principle, a rule abstraction that is open to new tax and discount behavior without edits under the Open/Closed Principle, and a refined discount rule that honors its parent's contract under Liskov Substitution.

30 minRead โ†’
Chapter 4

SOLID II: interface segregation, dependency inversion, and DI without a framework

Segregating a fat interface into focused role interfaces, inverting the dependency between a high-level policy and a low-level implementation, and composing the resulting object graph by hand, in idiomatic C++ with no DI container.

30 minRead โ†’
โ† Previous part Recognizing Design Next part โ†’ The C++ Substrate
Design Patterns with C++
Tutorial content: CC BY 4.0. Sample code: Apache 2.0.
Source on GitHub โ†—  ยท  File an issue โ†—