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

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.
主站蜘蛛池模板: 泸西县| 遂昌县| 宁城县| 安新县| 枝江市| 盱眙县| 朝阳县| 林芝县| 启东市| 林芝县| 青冈县| 马山县| 临沂市| 城固县| 额尔古纳市| 聂荣县| 巴彦县| 竹北市| 嘉善县| 龙川县| 康马县| 棋牌| 安陆市| 赞皇县| 仪征市| 上林县| 霍林郭勒市| 乡城县| 芷江| 灵丘县| 饶河县| 浮山县| 汉沽区| 东光县| 滦平县| 甘谷县| 青铜峡市| 佛冈县| 阳西县| 临泉县| 高平市|