𝔖 Scriptorium
✦   LIBER   ✦

📁

Design Patterns in Modern C++20: Reusable Approaches for Object-Oriented Software Design

✍ Scribed by Dmitri Nesteruk


Publisher
Apress
Year
2021
Tongue
English
Leaves
391
Edition
2
Category
Library

⬇  Acquire This Volume

No coin nor oath required. For personal study only.

✦ Synopsis


Apply the latest editions of the C++ standard to the implementation of design patterns. As well as covering traditional design patterns, this book fleshes out new design patterns and approaches that will be useful to modern C++ developers. Author Dmitri Nesteruk presents concepts as a fun investigation of how problems can be solved in different ways, along the way using varying degrees of technical sophistication and explaining different sorts of trade-offs.

Design Patterns in Modern C++20, Second Edition also provides a technology demo for modern C++, showcasing how some of its latest features (e.g., coroutines, modules and more) make difficult problems a lot easier to solve. The examples in this book are all suitable for putting into production, with only a few simplifications made in order to aid readability.

What You Will Learn

  • Use creational patterns such as builder, factories, prototype and singleton
  • Implement structural patterns such as adapter, bridge, decorator, facade and more
  • Work with the behavioral patterns such as chain of responsibility, command, iterator, mediator and more
  • Apply functional design patterns such as the Maybe Monad

Who This Book Is For

This book is for both beginner and experienced C++ developers.

✦ Table of Contents


Table of Contents
About the Author
About the Technical Reviewers
Chapter 1: Introduction
Who This Book Is For
On Code Examples
On Developer Tools
Preface to the Second Edition
Important Concepts
Curiously Recurring Template Pattern
Mixin Inheritance
Old-Fashioned Static Polymorphism
Static Polymorphism with Concepts
Properties
The SOLID Design Principles
Single Responsibility Principle
Open-Closed Principle
Liskov Substitution Principle
Interface Segregation Principle
Dependency Inversion Principle
Part I: Creational
Chapter 2: Builder
Scenario
Simple Builder
Fluent Builder
Communicating Intent
Groovy-Style Builder
Composite Builder
Builder Parameter
Builder Inheritance
Summary
Chapter 3: Factories
Scenario
Factory Method
Factory
Factory Methods and Polymorphism
Nested Factory
Abstract Factory
Functional Factory
Object Tracking
Summary
Chapter 4: Prototype
Object Construction
Ordinary Duplication
Duplication via Copy Construction
Virtual Constructor
Serialization
Prototype Factory
Summary
Chapter 5: Singleton
Singleton As Global Object
Classic Implementation
Thread Safety
The Trouble with Singleton
Per-Thread Singleton
Ambient Context
Singletons and Inversion of Control
Monostate
Summary
Part II: Structural
Chapter 6: Adapter
Scenario
Adapter
Adapter Temporaries
Bidirectional Converter
Summary
Chapter 7: Bridge
The Pimpl Idiom
Bridge
Summary
Chapter 8: Composite
Array-Backed Properties
Grouping Graphic Objects
Neural Networks
Shrink-Wrapping the Composite
Conceptual Improvements
Concepts and Global Operators
Composite Specification
Summary
Chapter 9: Decorator
Scenario
Dynamic Decorator
Static Decorator
Functional Decorator
Summary
Chapter 10: Façade
Magic Square Generator
Fine-Tuning
Building a Trading Terminal
An Advanced Terminal
Where’s the Façade?
Summary
Chapter 11: Flyweight
User Names
Boost.Flyweight
String Ranges
Naïve Approach
Flyweight Implementation
Summary
Chapter 12: Proxy
Smart Pointers
Property Proxy
Virtual Proxy
Communication Proxy
Value Proxy
Summary
Part III: Behavioral
Chapter 13: Chain of Responsibility
Scenario
Pointer Chain
Broker Chain
Summary
Chapter 14: Command
Scenario
Implementing the Command Pattern
Undo Operations
Composite Command
Command Query Separation
Summary
Chapter 15: Interpreter
Parsing Integral Numbers
Numeric Expression Evaluator
Lexing
Parsing
Using the Lexer and Parser
Parsing with Boost.Spirit
Abstract Syntax Tree
Parser
Printer
Summary
Chapter 16: Iterator
Iterators in the Standard Library
Traversing a Binary Tree
Iteration with Coroutines
Summary
Chapter 17: Mediator
Chat Room
Mediator with Events
Service Bus As Mediator
Summary
Chapter 18: Memento
Bank Account
Undo and Redo
Memory Considerations
Using Memento for Interop
Summary
Chapter 19: Null Object
Scenario
Null Object
shared_ptr Is Not a Null Object
Design Improvements
Implicit Null Object
Interaction with Other Patterns
Summary
Chapter 20: Observer
Property Observers
Observer
Observable
Connecting Observers and Observables
Dependency Problems
Unsubscription and Thread Safety
Reentrancy
Observer with Boost.Signals2
Views
Summary
Chapter 21: State
State-Driven State Transitions
Handmade State Machine
Switch-Based State Machine
State Machines with Boost.MSM
Summary
Chapter 22: Strategy
Dynamic Strategy
Static Strategy
Summary
Chapter 23: Template Method
Game Simulation
Functional Template Method
Summary
Chapter 24: Visitor
Intrusive Visitor
Reflective Printer
What Is Dispatch?
Classic Visitor
Implementing an Additional Visitor
Acyclic Visitor
Variants and std::visit
Summary
Index


📜 SIMILAR VOLUMES


Design Patterns in Modern C++20: Reusabl
✍ Dmitri Nesteruk 📂 Library 📅 2021 🏛 Apress 🌐 English

<p>Apply the latest editions of the C++ standard to the implementation of design patterns. As well as covering traditional design patterns, this book fleshes out new design patterns and approaches that will be useful to modern C++ developers. Author <b>Dmitri Nesteruk</b> presents concepts as a fun

Design Patterns in Modern C++20: Reusabl
✍ Dmitri Nesteruk 📂 Library 📅 2021 🏛 Apress 🌐 English

<p>Apply the latest editions of the C++ standard to the implementation of design patterns. As well as covering traditional design patterns, this book fleshes out new design patterns and approaches that will be useful to modern C++ developers. Author <b>Dmitri Nesteruk</b> presents concepts as a fun

Design Patterns in Modern C++. Reusable
✍ Dmitri Nesteruk 📂 Library 📅 2018 🏛 Apress 🌐 English

Apply modern C++17 to the implementations of classic design patterns. As well as covering traditional design patterns, this book fleshes out new patterns and approaches that will be useful to C++ developers. The author presents concepts as a fun investigation of how problems can be solved in differe

Design Patterns in Modern C++: Reusable
✍ Dmitri Nesteruk 📂 Library 📅 2018 🏛 Apress 🌐 English

<div>Apply modern C++17 to the implementations of classic design patterns. As well as covering traditional design patterns, this book fleshes out new patterns and approaches that will be useful to C++ developers. The author presents concepts as a fun investigation of how problems can be solved in di

Design Patterns in Modern C++: Reusable
✍ Dmitri Nesteruk 📂 Library 📅 2018 🏛 Apress 🌐 English

<div>Apply modern C++17 to the implementations of classic design patterns. As well as covering traditional design patterns, this book fleshes out new patterns and approaches that will be useful to C++ developers. The author presents concepts as a fun investigation of how problems can be solved in di

Design Patterns in .Net: Reusable Approa
✍ Dmitri Nesteruk 📂 Library 📅 2019 🏛 Apress 🌐 English

Implement design patterns in .NET using the latest versions of the C# and F# languages. This book provides a comprehensive overview of the field of design patterns as they are used in today's developer toolbox.<br /><br />Using the C# programming language, <i>Design Patterns in .NET</i> explores the