The Observer Design Pattern in Cpp
summary
Concrete C++ code evolves from a naive single-function handler to interface-based observers to a keyed map of observer lists (example3.cpp uses shared_ptrs) showing notify all vs notify type and the removal case that exposed dangling-pointer hazards, so the pattern decouples sound/physics/logging but costs ownership and performance tradeoffs. References include Angry Birds example, Game Programming Patterns, Java util.Observer, Godot/Qt signals, Blender, Maya, Ogre3D; recommends shared_ptr and weak_ptr and considers templates, concepts, queues or actor models for scale.
AI-written summary · about
chapters (12)
- 0:00Observer pattern intro
- 4:57Why this talk exists
- 9:08Behavioral patterns basics
- 13:41First implementation
- 18:18Problems with first impl
- 20:27Interfaces and inheritance
- 29:24Type-specific event handling
- 38:56Evaluating third impl
- 43:33Real-world usage
- 51:00Scaling in Angry Birds
- 53:27Modernizing the pattern
- 1:00:18Q&A
related talks
01h 20mRevisiting C++ Observers: Spooky Action at a Distance
01h 03mSpooky Action at a Distance
04mUsing a Smart Event Dispatcher in C++
21mObserver Driven Design
33mThe Observer tip-jar
29mA Design Pattern Goes to the Supermarket
24mA Few Good Design Patterns
01h 00mHow to Use Dependency Injection to Write Maintainable Software
