From the course: Programming Foundations: Design Patterns
Unlock the full course today
Join today to access over 24,000 courses taught by industry experts.
Challenge: The Observer pattern
From the course: Programming Foundations: Design Patterns
Challenge: The Observer pattern
(high energy music) - [Narrator] The observer pattern can be used to loosely couple objects together. Whenever you have objects that want to be notified when another object is updated. In this challenge, you'll design a weather station and various classes that are interested in the weather station's data. Including a user interface, a logger, and an alert system. The weather station has a set of sensors that are used to measure temperature, wind speed, and pressure. The user interface, logger, and alert system are all interested in the data, and want to be notified when the weather station gets new data from the sensors. Make sure your design allows for other observers to easily be added to the design. For instance, you might want your business to get notified by the weather station too, and you don't want to have to change the code in the weather station.
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.