课程: Programming Foundations: Design Patterns
今天就学习课程吧!
今天就开通帐号,24,100 门业界名师课程任您挑!
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…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。