Modern Object-Oriented C++ is a two-day training course with programming examples taught by Arthur O’Dwyer. It is offered onsite at the Gaylord Rockies from 09:00 to 17:00 on Saturday, October 30th and Sunday, October 31st, 2021 (immediately after the conference). Lunch is included.
Course Description
Modern C++ is full of new ideas, from constexpr
to coroutines. But among industry codebases, the most popular paradigm remains classical object-oriented programming: runtime polymorphism based on inheritance hierarchies and heap allocation. In this course we’ll cover modern C++’s continuing and evolving support for classical inheritance from top to bottom: from modern OOP idioms, to the machine-level mechanisms by which C++ implements (multiple) inheritance, virtual dispatch, and runtime type information (RTTI). We’ll also cover techniques for managing complexity, from smart pointers and factory functions to dependency injection and the PIMPL idiom. One unit will focus specifically on interaction testing with Google Mock.
Attendees will practice their skills with a series of hands-on lab exercises, using their own C++14-or-later development environment.
Prerequisites
This course will be valuable for anyone inheriting or maintaining a codebase filled with classical OOP, from new grads to experienced software engineers
Course Topics
Simple inheritance, IS-A, vtables, override
, managing memory with unique_ptr
(+ lab)
- Where is the vptr in the class layout?
- Why is
override
important? - Should I use
final
?
Best practices: Shallow hierarchies, abstract base classes, deleted special members, NVI (+ lab)
- Why are deep hierarchies bad?
- How do I deal with an existing deep hierarchy?
- Why should I delete my special member functions?
- How does the Non-Virtual Interface idiom relate to the GoF’s Template Method pattern?
- Should overriding methods be marked
public
, orprivate
? - How abstract must my abstract base class be, really?
Hiding dependencies in the .cpp
file, factory functions, protected
(+ lab)
- Should I mark my constructors as
private
and/orprotected
? - What if my methods’ return types involve third-party dependencies?
- What is dependency injection?
- When might I want a
Foo::create()
method instead of a constructor? - What is the PIMPL idiom? How do I combine it with smart pointers?
Google Mock and “interaction testing” (+ lab)
- How do I use Google Mock?
Virtual and multiple inheritance, non-trivial static_casts, drawing inheritance diagrams (+ lab)
- When are virtual bases’ constructors called?
- Mechanics of non-trivial static_casts
- Mechanics of accessing a data member from a virtual base
dynamic_cast
, catch
, and typeid/RTTI (+ lab)
- Mixin pattern
- Speed-minded alternatives to
dynamic_cast
Register Here
Course Instructor
Arthur O’Dwyer is a speaker, trainer, and blogger on modern C++ topics. He has spoken at every CppCon since its inception in 2014, and is the chair of the Back to Basics track that debuted at CppCon 2019. Arthur is the author of Mastering the C++17 STL (2017). He lives and works in New York.