随笔分类 -  DOTA中看设计模式

摘要:一、概念策略模式(Strategy):它定义了一系列的算法,并将每一个算法封装起来,而且使它们还可以相互替换。策略模式让算法的变化不会影响到使用算法的客户。(原文:The Strategy Pattern defines a family of algorithms,encapsulates eachone,and makes them interchangeable. Strategy lets the algorithm varyindependently from clients that use it.)二、类图三、存储记忆:在你的大脑里记下类图,同时理解算法簇 (1)Context( 阅读全文
posted @ 2012-07-17 20:59 hktkhhhh 阅读(328) 评论(0) 推荐(0)
摘要:一、概念装饰者模式(Strategy):它动态将职责附加到对象上,若要扩展功能,装饰者提供了比继承更具弹性的代替方案。(原文:The Decorator Pattern attaches additional responsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing for extending functionality.)二、类图三、存储记忆:在你的大脑里记下类图,同时理解以下对象的职责与行为 (1)Component(被装饰对象基类) 定义对象的接口 阅读全文
posted @ 2012-07-17 20:57 hktkhhhh 阅读(351) 评论(0) 推荐(0)
摘要:一、概念观察者模式(Strategy):它定义了对象间的一种一对多依赖关系,使得每当一个对象改变状态,则所有依赖于它的对象都会得到通知并被自动更新。(原文:The Observer Pattern defines a one-to-many dependency between objects so that when one object changes state, all of its dependents are notified and updated automatically.)二、类图三、存储记忆:在你的大脑里记下类图,同时理解以下对象的职责与行为(1)Subject(被观察的 阅读全文
posted @ 2012-07-17 20:56 hktkhhhh 阅读(450) 评论(0) 推荐(0)