Behavioral Patterns
notifyObservers()
, causing each observer’s update method to run. This decouples subjects and observers.
ConcreteSubject
maintains a list of observers. Whenever its internal state changes
(some_business_logic), it calls notify()
, which in turn calls update()
on each attached observer (ConcreteObserverA
,
ConcreteObserverB
).