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

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.
主站蜘蛛池模板: 顺平县| 南靖县| 土默特左旗| 濮阳市| 麦盖提县| 深圳市| 高尔夫| 平湖市| 内乡县| 荥经县| 略阳县| 喀喇沁旗| 丹巴县| 徐水县| 临泉县| 咸宁市| 唐河县| 马龙县| 庄浪县| 永康市| 绩溪县| 左云县| 阳原县| 勃利县| 晋江市| 秭归县| 偃师市| 社旗县| 宜兴市| 平阳县| 呼和浩特市| 锡林浩特市| 绥棱县| 察雅县| 奉贤区| 板桥市| 简阳市| 奈曼旗| 陕西省| 新源县| 凌海市|