From the course: Programming Foundations: Design Patterns
Unlock the full course today
Join today to access over 24,000 courses taught by industry experts.
Understanding the Observer pattern
From the course: Programming Foundations: Design Patterns
Understanding the Observer pattern
- The observer pattern exemplifies the design principle of loose coupling. This principle tells us to strive for loosely coupled designs between objects that interact. What are loosely coupled objects? We say that objects are loosely coupled when they interact with one another, which makes them coupled, but they don't know a lot about each other, which makes them loosely coupled. With loose coupling, objects don't become too dependent on each other. As we'll see, this helps to keep our design more flexible. For instance, with the observer pattern, loose coupling helps us to minimize the complexity of a scenario where there are a lot of objects coming and going during a computation, and those objects need to be kept up to date on an important piece of data or a set of events. The observer pattern is one of the most commonly used patterns. You'll use it in your own code, and you'll see it used in many libraries and…
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.