What problem does the observer pattern solve?
- A.Limiting how many components may access an object
- B.Several parties need to know when something changes, and the source need not know who
- C.Monitoring the performance of the system's components
- D.Recording an object's whole change history over time
Answer: B
When many parties need to react to a change but the emitter doesn't need to know who they are: an event source, and subscribers that listen. Adding a new listener doesn't require changing the source.
References