摘要: 观察者模式:定义了一种一对多的依赖关系,让多个观察者对象同时监听某一个主体对象,这个主题对象在状态发生变化时,会通知所有观察者。当一个对象改变需要同时改变其他对象,而且他不知道具体有多少对象需要改变的时候,应该考虑使用观察者模式。Define a one-to-many dependency between objects so that when one objects changes state,all its dependents are notified and updated automatically.观察者结构图: 代码: public abstract class Sub... 阅读全文
posted @ 2013-11-05 17:42 nygfcn 阅读(184) 评论(0) 推荐(0)
摘要: 中介者模式(Mediator Pattern),定义一个中介对象来封装系列对象之间的交互。中介者使各个对象不需要显示地相互引用,从而使其耦合性松散,而且可以独立地改变他们之间的交互。 Define an object that encapsulates how a set of objects interact. Mediator promotes loose coupling by keeping objects from referring to each other explicitly, and it lets you vary their interaction independen 阅读全文
posted @ 2013-11-05 15:59 nygfcn 阅读(299) 评论(0) 推荐(0)