From the course: Programming Foundations: Design Patterns

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Understanding the Observer pattern

Understanding the Observer pattern

From the course: Programming Foundations: Design Patterns

Start my 1-month free trial

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 frameworks. And, like the adapter pattern, the observer pattern is…

Contents