Purpose and task Objective: familiar with the UML, familiar with the observer, the memo mode. Tasks: in accordance with the requirements of the experiment content, complete use of the observer, the memo mode to achieve experimental content. |
|||||||||
Content preview Review the contents of the course, familiar with the viewer, using the Memo mode. |
|||||||||
Experiment contents and requirements
1, commodities names, prices and other information, such as price discounts will change, the price will automatically notify the user of the goods concerned if changes, please combined with the observer pattern, design a class diagram and give the relevant code.
|
|||||||||
The results (available Continued) One: Subject (target):
ConcreteSubject(具体目标):
Observer(观察者):
ConcreteObserver(具体观察者):
Main:
类图: 结果: 二: Originator(原发器):
Memento(备忘录):
Caretaker(负责人):
Main: 结果: 类图:
思考题:
观察者模式.
2、假设有两个网站site1、site2,当一个用户进入site1后,使用了session来记录。当用户现在访问site2一段时间,这时用户访问site1就会session失效,请问如何保存session来解决这个问题? 通过备忘录模式解决。用户一开始访问site1时开启备忘录模式,将session信息备份一边,当用户访问site2一段时间后再访问site1,打开备忘录模式,将备份的session信息导出替换。
|
Observer, the memo mode
Guess you like
Origin blog.csdn.net/yszbrzdd/article/details/93376425
Recommended
Ranking