The Observer pattern defines a one-to-many dependency where multiple objects (observers) are notified automatically when another object (the subject) changes state. It enables decoupled, event-driven communication — widely used in UIs, event systems, and reactive programming.
What the Observer pattern does
OBSERVER → a SUBJECT maintains a list of OBSERVERS and NOTIFIES them on state changes:
→ observers SUBSCRIBE to the subject
→ when the subject changes → it notifies ALL subscribed observers automatically
→ observers react to the notification (update themselves)
→ one-to-many: one subject, many observers; DECOUPLED (subject doesn't know observer details)
