Observer Pattern
# Observer Pattern
# Problems we want to solve
- Tight coupling due to a 1-many dependency
- We need a number of dependent objects to update automatically when one object changes state
- We need an object to notify a number of other objects
# Push / Pull Mechanisms
**Pull
- 2-way communication: Subject sends a notification and the observer calls back for details explicitly (can be used for selective notification based on interest) **Push
- 1-way communication: Subject sends the detailed information whether the observer wants it or not (can be used for sending updates based on location etc.)
# Example Class Diagrams
# Pros
- Abstracts coupling between Subject and Observer
- Supports broadcast communication
- Enable reusability of subjects and observers
# Cons
- Slower performance
- Possible unnecessary complexity