Book Review – Design Patterns in Modern C++

Written by on July 22, 2018 in Book Review, C++ with 0 Comments

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

Author: Dmitri Nesteruk

Publisher: Apress

Year: 2018

Luck has been on my side for the past few weeks; I have been getting access to nice books to read. I wrote about The Modern C++ Challenge in my last post. Today, I am going to review another nice book.

Since the original GoF book, much has been written and talked about Design Patterns. They are the bread and butter of every serious software developer. The C++ examples given in the GoF book are somewhat outdated now because the language itself has evolved significantly over this long period. So it is refreshing to see a book that focusses entirely on Design Patterns using the latest C++ standard.

The presentation format of the various design patterns is different in this book compared to the original GoF book. In the latter, each pattern is explained using various sections such as Intent, Motivation, Applicability, and so on. In this book, however, that template is not followed. It is somewhat of a linear presentation with several examples. I find this acceptable because the book’s purpose is not to teach design patterns, but to present the classic patterns in the context of the current C++ standard. What this means is that if you are new to design patterns, then you are better off starting with the GoF book and then coming back to this book for the specifics of C++ implementation. I doubt if anyone can do better than the GoF book in terms of explaining the concepts.

One thing I like about this book is that the author describes important C++ concepts (e.g. Curiously Recurring Template Pattern) and also the SOLID design principles in the first chapter, before describing the actual patterns. This is very helpful since it lays the foundation for the following chapters.The author also warns us that adopting certain patterns (e.g. Observer) might sometimes result in overengineering. I couldn’t agree more! One has to understand the various design patterns and apply them judiciously while implementing real-world projects.

All the patterns described in the GoF are covered in this book as well, and more or less, in the same order. 

1. Creational Patterns:

– Builder

– Factories (Abstract factory and Factory Method)

– Prototype

– Singleton

2. Structural Patterns:

– Adapter

– Bridge

– Composite

– Decorator

– Facade

– Flyweight

– Proxy

3. Behavioral Patterns:

– Chain of Responsibility

– Command

– Interpreter

– Iterator

– Mediator

– Memento

– Null Object 

– Observer

– State

– Strategy

– Template Method

– Visitor

The Null Object pattern under Behaviour Patterns was not described in the GoF book, but subsequently appeared in Pattern Languages of Program Design, Volume 3. 

A nice bonus is the discussion on Maybe Monad in the Appendix. Monads are originally from Haskell and there are libraries attempting to support them in other languages such as Python, Ruby and Lisp. It is interesting to learn about it from C++ point of view. 

I must say I thoroughly enjoyed reading this book and I recommend it highly. If you are a serious C++ developer, just go and buy it!

I found two interesting sites that discuss C++ Design Patterns. See this and this.

(P.S. I am also reading a couple of other good books on C++ Concurrency and Designing DSLs. So don’t be surprised if I continue with book reviews in the next few posts as well!)

Have a great weekend!

Tags: ,


If you enjoyed this article, subscribe now to receive more just like it.

Subscribe via RSS Feed

Leave a Reply

Your email address will not be published. Required fields are marked *