今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
The Observer pattern
- [Instructor] The most common analogy for the observer design pattern is a newspaper subscription. Households can subscribe to particular newspapers. When a new paper is printed the news organization delivers that paper to all of its subscribers. The observer design pattern implements a similar approach. Objects, called observers, can watch other objects for state changes. These objects that can broadcast changes are known as observables. In this example, a stoplight is an observable object. Other objects can subscribe to the stoplight and watch it for state changes. For example, a bike, a car, a bus. They're all different types of objects, but they can all watch the stoplight object for changes and respond accordingly. When the state of the stoplight changes, say from red to green, it can notify every object that has subscribed to it of this state change. The key is that each observer object implements a method that…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。
内容
-
-
-
-
-
-
(已锁定)
Chain of responsibility4 分钟 42 秒
-
(已锁定)
Implementing the storage class6 分钟 22 秒
-
(已锁定)
The Command pattern4 分钟 47 秒
-
(已锁定)
Implementing commands4 分钟 59 秒
-
(已锁定)
Improving the conductor6 分钟 38 秒
-
(已锁定)
The Iterator pattern4 分钟 5 秒
-
(已锁定)
Implementing iterators4 分钟 59 秒
-
(已锁定)
The Observer pattern4 分钟 19 秒
-
(已锁定)
Implementing observers2 分钟 48 秒
-
(已锁定)
The Strategy pattern4 分钟 25 秒
-
(已锁定)
Implementing strategies9 分钟 36 秒
-
(已锁定)
-