🎨 Design Patterns (Gang of Four)
Beginner
What is the Observer design pattern?
Answer
The Observer pattern defines a one-to-many dependency between objects so that when one object (the Subject or Publisher) changes state, all its dependents (Observers or Subscribers) are notified and updated automatically. This is the foundation of event-driven systems. Examples include: a spreadsheet where formulas (observers) automatically recalculate when a cell (subject) value changes, and a news agency that notifies all subscribed news feeds when a new story is published. Java's Observer/Observable (deprecated), JavaScript's EventEmitter, and reactive frameworks all implement this pattern.