Design Patterns in C++: Behavioral - Observer to Visitor

This course will teach you about behavioral design patterns and their implementation in modern C++. It covers the Observer, State, Stategy, Template Method, and Visitor patterns.
Course info
Rating
(23)
Level
Intermediate
Updated
Sep 22, 2016
Duration
2h 0m
Table of contents
Description
Course info
Rating
(23)
Level
Intermediate
Updated
Sep 22, 2016
Duration
2h 0m
Description

The correct application and recognition of design patterns is an important skill for developers and architects. This course, Design Patterns in C++: Behavioral - Observer to Visitor, part of a multi-series course on C++ patterns, continues to introduce the viewer to Behavioral design patterns. It covers the Observer, State, Stategy, Template Method, and Visitor patterns, showing different ways in which these patterns can be implemented in modern C++ (C++ 11 and beyond). Software required: a C++ IDE (e.g., Visual Studio, CLion) or a text editor (e.g., VIM, EMACS) together with a C++ compiler (e.g., GCC, Clang).

About the author
About the author

Dmitri is a developer, speaker, podcaster, technical evangelist and wannabe quant.

More from the author
ReSharper Fundamentals
Intermediate
2h 54m
Apr 28, 2017
More courses by Dmitri Nesteruk
Section Introduction Transcripts
Section Introduction Transcripts

Course Overview
Hi everyone. My name is Dmitri Nesteruk and I'm happy to welcome you to this course on behavioral design patterns in the C++ programming language. Now, I am myself a quantitative analyst who enjoys programming C++ and its applications to finance and high performance computing. Now, the original design patterns book was written using small talk and C++ a very long time ago, so you can consider this course as a bit of an update, taking the design patterns into the ear of modern C++. This course is the fifth part of a five course series on C++ design patterns, and happens to cover the second half of the behavioral design patterns, and the way they're implemented in C++. So, the patterns we cover in the course are the following. We cover Observer, State, Strategy, Template method, and Visitor. And by the end of the course, you should know how to implement these behavioral patterns in C++. Now, before jumping into the course, you should have a reasonably good knowledge of C++. So I hope you'll join me on this journey to learn behavioral design patterns with the C++ behavioral design patterns course here on Pluralsight.

Observer
Hi there. My name is Dmitri and I'm very happy to welcome to you this course on design patterns in C++ Observer to Visitor. So what are we going to see in this course? Well, first of all, I have to mention the fact that this is the fifth and final course in a series of courses on C++ Design Patterns here on Pluralsight. And this course that you're looking at right now covers the second half of the behavior design patterns, starting with observer and ending with visitor. So just like all the other courses in this series, we try to cover every single pattern from the Gang of Four book. And in a typical course structure, we talk about the motivation for using each of the patterns. We look at classic implementations of those patterns. We look at pattern variations and library implementations. We also talk about the way that patterns can interact with one another and we discuss any important considerations with regards to using the patterns, such as testability, for example. All the patterns are demonstrated exclusively via live coding. This course is built out of a series of demos. All of the demos are using the modern variety of C++. So that's C++ 11, 14 and even 17 in places. All the demonstrations are done using Visual Studio 2015, Microsoft Visual Studio Compiler as well as ReSharper C++. I did make a few simplifications, however, for the purposes of better flow of the demos. For example, I typically have classes defined in inline so there is no header/CPP separation. I often do pass by value, even in cases when it's not particularly efficient. And I make liberal use of the import of entire namespaces, such as STD or or Boost as well as the corresponding headers. So the structure of this course is fairly simple. We'll talk about the five patterns from the second half of the behavioral patterns. So that's going to be observer, state, strategy, template method, and finally, visitor.

State
Hi there. In this module we're going to talk about the state design pattern. So what we're going to see in this module is the following. First of all, we'll talk about the motivation for using the state design pattern. Then we're going to build a handmade state machine and then we're going to use the Boost. MSM library to see how it's done it serious production code. And we're also going to talk about some of the concerns related to state machines such as the ability to define actions and guards on different transitions.

Strategy
Alright, so, in this module, we're going to talk about the strategy design pattern, and the content of this module is actually fairly short, because after talking about the motivation for using strategy, we'll take a look at just two examples. The first example will be the use of the strategy design pattern in a dynamic setting, that's the most common use of the pattern to actually enable you to change the strategy that you're using to do something at run-time, but we'll also take a look at the static approach, essentially have the strategy as a template argument that's designed at compile-time.

Template Method
In this module we're going to take a look at the Template Method design pattern. And this is going to be a very brief module. So we're going to take a look at the motivation for using Template Method and then we're actually going to implement it in code and see how it's all done.

Visitor
Hi there! In this module we're going to talk about the visitor design pattern. So what we're going to discuss is, as always, we'll discuss the motivation for using visitor. Then we'll take a look at a straightforward implementation of a static visitor, but then we'll talk about something called double dispatch, which is the most common way of actually implementing visitor. And we'll also talk about a side topic called multiple dispatch, which applies not just to the visitor pattern, but to programming in C++ generally.