The Observer Pattern: Keeping your Objects in the know

HFDP

Read HFDP online

2: The Observer Pattern: Keeping your Objects in the know

https://ucsb-cs56-pconrad.github.io/hfdp/HFDP_Chapter_2/

TODO: Fill in HFDP_Chapter_2.md with notes for Chapter 2 of HFDP.

The Weather Monitoring application overview

Unpacking the WeatherData class

What do we know so far?

Taking a first, misguided SWAG at the Weather Station

What’s wrong with our implementation?

Meet the Observer Pattern

Publishers + Subscribers = Observer Pattern

A day in the life of the Observer Pattern

Five-minute drama: a subject for observation

Two weeks later…

The Observer Pattern defined

The Observer Pattern defined: the class diagram

The power of Loose Coupling

Cubicle conversation

Designing the Weather Station

Implementing the Weather Station

Implementing the Subject interface in WeatherData

Now, let’s build those display elements

Power up the Weather Station

Using Java’s built-in Observer Pattern

How Java’s built-in Observer Pattern works

Reworking the Weather Station with the built-in support

Running the new code

The dark side of java.util.Observable

Other places you’ll find the Observer Pattern in the JDK

And the code…

Tools for your Design Toolbox

https://ucsb-cs56-pconrad.github.io/hfdp/HFDP_Chapter_2/