ITeye博客

2008 年文章归档

共 2 篇文章

设计模式之观察者模式

一、定义 参考"Gang of Four"所著的设计模式一书对观察者模式的定义:"a one-to-many dependency between objects so that when one object changes state, all of its dependents are notified and updated automatically." 在对象之间定义一对多依赖,当一个对象改变状态,依赖它的对象都会收到通知,并自动更新。这个模式用到的设计原则就是“为交互对象之间的松耦合而努力”。 观察者模式又叫发布-订阅(Publish/Subscribe)模式、模型-视图(Mo…

2008-11-07 14:03 · 设计模式 · UML · Swing · 设计模式 · thread · 多线程

设计模式之策略模式

一、 策略模式定义 参考Gang of Four's (GOF) Design Patterns书里的定义: Define a family of algorithms, encapsulate each one, and make them interchangeable. [The] Strategy [pattern] lets the algorithm vary independently from clients that use it 策略模式(Strategy)属于对象行为型设计模式,主要是定义算法族,分别封装起来,让他们之间可以项目替换,此模式让算法的变化独立于使用算法的客…

2008-11-04 18:08 · 设计模式 · 算法 · 项目管理 · OOP · 编程 · 设计模式