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

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.
主站蜘蛛池模板: 宁乡县| 常熟市| 衢州市| 宜兴市| 新郑市| 宁晋县| 当阳市| 陵水| 沈丘县| 会泽县| 平罗县| 鸡西市| 灵丘县| 汶上县| 涟源市| 沾益县| 全州县| 九龙坡区| 清河县| 广元市| 弥渡县| 阿坝县| 沈丘县| 襄垣县| 大姚县| 武胜县| 余姚市| 花莲县| 福泉市| 汕尾市| 汶上县| 金秀| 石门县| 双流县| 易门县| 静安区| 桑日县| 南昌市| 新营市| 河北区| 大渡口区|