๐Ÿงฉ Design Patterns with C++
Home Chapters Examples Diagrams Bibliography GitHub โ†—
  1. Home
  2. The C++ Substrate
Part 3 3 chapters

The C++ Substrate

RAII and deterministic lifetimes, value semantics and smart-pointer ownership, and proving a design works with GoogleTest before the patterns chapters begin.

Chapter 5

RAII and deterministic lifetimes

Tying a resource's lifetime to an object's lifetime instead of a bool flag a caller has to remember: acquire in the constructor, release in the destructor, exception-safe by construction, taught against a warehouse dock-bay lease and a general-purpose scope-exit utility.

25 minRead โ†’
Chapter 6

Value semantics, ownership, and smart pointers

Four ownership shapes in a warehouse dispatch system: a value type that follows the Rule of Zero, sole ownership transferred by move with unique_ptr, a resource-owning Rule of Five type shared by shared_ptr, and a parent/child object graph where weak_ptr breaks a reference cycle.

30 minRead โ†’
Chapter 7

Proving it works: testing with GoogleTest

The shared testing foundation every pattern in this book is verified against: GoogleTest fixtures, parameterized and typed tests, GoogleMock interaction tests, and death tests, taught against a freight carrier's quote intake component.

30 minRead โ†’
โ† Previous part Principles (SOLID, Martin) Next part โ†’ Selecting and Varying Behavior
Design Patterns with C++
Tutorial content: CC BY 4.0. Sample code: Apache 2.0.
Source on GitHub โ†—  ยท  File an issue โ†—