Observer
Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.
The Problem
You have an object whose state other objects depend on. Polling is wasteful — every dependent checks the object repeatedly. Direct coupling is brittle — the subject has to know every dependent by type and call them manually.
Structure
Execution Walkthrough
Subscribe
Observers register themselves with the Subject by calling subscribe(). The Subject stores callbacks in a list.
State changes
notify() fires
Each update()
Decoupled
Code Comparison
Full C++ Implementation
Participants
Where it is used
EDA simulators
Xcelium's event-driven propagation — a signal change notifies all sensitive processes registered to that net.
Qt framework
Signals and slots: QPushButton::clicked() notifies any slot connected to it — GUI decoupled from logic.
Node.js
EventEmitter.on('data', cb) — fs.ReadStream notifies all listeners on each chunk read from disk.
Financial systems
A market data feed notifies strategy engines, risk monitors, and loggers simultaneously on each tick.