Brendan Ang

Search

Search IconIcon to open search

Observer Pattern

Last updated Nov 8, 2022 Edit Source

# Observer Pattern

# Problems we want to solve

  1. Tight coupling due to a 1-many dependency
  2. We need a number of dependent objects to update automatically when one object changes state
  3. We need an object to notify a number of other objects

# Push / Pull Mechanisms

**Pull

# Example Class Diagrams

# Pros

  1. Abstracts coupling between Subject and Observer
  2. Supports broadcast communication
  3. Enable reusability of subjects and observers

# Cons

  1. Slower performance
  2. Possible unnecessary complexity