Modern C++ Design Patterns

Klaus Iglberger

one day workshop
intermediate
advanced
10:30-19:15, Wednesday, 30th June 2021

Design patterns have proven to be useful over several decades and knowledge about them is still very useful to design robust, decoupled systems. Modern C++, however, has profoundly changed the way we use C++, think about design and implement solutions. This 1-day workshop explores modern C++ design and the modern forms of the classical design patterns. It will provide a deeper understanding of software design in general and design patterns in particular. It will give advice on how to decouple software systems and teach guidelines, idioms and best practices for sustainable and maintainable design. Amongst others it will answer the following questions:

  • How does good C++ design with a minimum of dependencies look like?
  • What are the most important rules for robust, maintainable, and sustainable design?
  • What are the most common pitfalls in C++ software design?
  • Why does classical C++ design based on inheritance hierarchies fail so often?
  • What is "Value Semantics"?
  • How are the classical design patterns realised in modern C++?
  • What are alternatives to the classical design patterns?
  • Which tools are available to support good C++ design?


Prerequisites

Course participants should have a solid base knowledge of C++ and at least one to two years of experience with the language. Additionally, the course is interesting for you if several of the following statements apply to you:

  • You are not aware of the impact of dependencies on code quality
  • You don’t know the SOLID principles or don’t consider them for your work
  • You believe object-oriented programming is about inheritance relationships
  • You consider moving functionality into classes the preferred design choice
  • You don’t comprehend the arcane rules when the compiler is generating the special member functions for you
  • You don’t know the details of move semantics
  • You want to reevaluate classic design patterns
  • You want to get an impression on modern C++ design patterns
  • You wonder about type erasure and expression templates or their value

Outline

Software Design & Design Patterns

  • The Goals of Software Design
  • The Purpose of Design Patterns
  • The Perils of Inheritance
  • Value Semantics vs. Reference Semantics

Classic Design Patterns Revisited

  • Visitor
  • Command
  • Prototype
  • Strategy
  • Observer
  • Decorator
  • Bridge
  • External Polymorphism

Modern C++ Design Patterns

  • Type Erasure
  • Expression Templates
  • CRTP

Programming Tasks

The hands-on programming tasks (including solutions) will be available for download via Dropbox at the beginning of the workshop. For the programming tasks, you are expected to use your own machine. Any operating system (Windows, Linux, MacOS, ...), any IDE/editor (MS Visual Studio, CLion, vi, emacs, ...) and any compiler capable of at least C++17 (GCC, Clang, MSVC, ...) can be used. For your convenience, both CMake and Make files will be provided. Please note that some programming tasks will require C++20 to compile.

Klaus Iglberger

Klaus Iglberger is a freelancing C++ trainer and consultant. He has finished his PhD in computer science in 2010 and since then is focused on large-scale C++ software design. He shares his experience in popular advanced C++ courses around the world (mainly in Germany, but also the EU and US). Additionally, he is the initiator and lead designer of the Blaze C++ math library (https://bitbucket.org/blaze-lib/blaze/src/master/) and a (co-)organizer of the Munich C++ user group (https://www.meetup.com/MUCplusplus/).