官术网_书友最值得收藏!

Implementation

The class diagram of the observer pattern is as follows:

The observer pattern relies on the following classes:

  • Subject: This is usually an interface that must be implemented by the classes and should be observable. The observers that should be notified are registered using the attach method. When they no longer have to be informed about the changes, they are deregistered using the detach method.
  • ConcreteSubject: This is a class that implements the subject interface. It handles the list of observers and it updates them about the changes.
  • Observer: This is an interface that is implemented by the objects that should be updated by the changes in the subject. Each observer should implement the update method, which informs them about the new state changes.
主站蜘蛛池模板: 昌黎县| 永安市| 宜春市| 清涧县| 沽源县| 高密市| 抚远县| 浦江县| 新营市| 安阳市| 开阳县| 巫山县| 榆林市| 莫力| 澄城县| 集贤县| 郴州市| 绩溪县| 都江堰市| 高清| 通山县| 梓潼县| 侯马市| 山阴县| 环江| 阳信县| 北碚区| 沙田区| 隆尧县| 方正县| 澄迈县| 监利县| 上蔡县| 无为县| 凌源市| 磴口县| 新巴尔虎右旗| 全南县| 九龙坡区| 黑河市| 巴彦淖尔市|