设计模式
iteye_5768
这个作者很懒,什么都没留下…
展开
-
设计模式的几条原则
1、单一职责原则 2、里氏替换原则 3、依赖倒置原则 4、借口隔离原则 5、迪米特法则 只跟最亲近的朋友发生关系。 6、开闭原则 对扩展开发,对修改关闭。 7、单工抽建原 适装组门桥享代 命状备访观迭责策中模解 ...原创 2011-03-08 10:55:02 · 82 阅读 · 0 评论 -
23-13,适配器模式
1、适配器模式(Adapter Pattern)的定义如下: Convert the interface of a class into another interface clients expect. Adapter lets classes work together thar couldn't otherwise because of incompatible interfaces(...原创 2011-03-17 11:30:15 · 67 阅读 · 0 评论 -
23-14,迭代器模式
1、迭代器模式原创 2011-03-17 11:34:14 · 63 阅读 · 0 评论 -
23-15,组合模式
1、组合模式(Composite Pattern)也叫组合模式,又是又叫部分-整体模式(Part-Whole),主要是用来描述部分与整体的关系,其定义如下: Compose objects into tree structures to represent part-whole hierarchies. Composite lets clients treat individual obje...原创 2011-03-17 12:08:04 · 67 阅读 · 0 评论 -
23-16,观察者模式
1、观察者模式(Observer Pattern)也叫发布订阅模式(Publish/subscribe),它是一个在项目中经常用到的模式。其定义如下:Define a one-to-many dependency between objects so that when one object changes state,all its dependents are notified and upd...原创 2011-03-17 12:08:36 · 50 阅读 · 0 评论 -
23-17,门面模式
1、门面模式(Facade Pattern)也叫外观模式,是一种比较常用的封装模式,其定义如下:Provide a unified interface to a set of interfaces in a subsystem.Facade defines a higher-level interface that makes the subsystem easier to use(要求一个子系统...原创 2011-03-17 12:09:04 · 63 阅读 · 0 评论 -
23-18、备忘录模式
1、备忘录模式(Memento Pattern)提供了一种弥补真实世界缺陷的方法,让“后悔药”在程序的世界中真实可行,其定义如下:Without voilating encapsulation, capture and externalize an object's internal state so that the object can be restored to this state la...原创 2011-03-17 12:09:44 · 80 阅读 · 0 评论 -
23-19,访问者模式
1、访问者模式(Visitor Pattern)是一个相对简单的模式,其定义如下:Represent an operation to bu performed on the elements of an object structure,Visitor lets you difine a new operation without changing the classes of the eleme...原创 2011-03-17 12:10:15 · 71 阅读 · 0 评论 -
23-20,状态模式
1、Allow an object to alter its behavior when its internal state changes. The object will appear to change its class.(当一个对象内在状态改变时允许其改变行为,这个对象看起来像改变了其类。) 状态模式的核心是封转,状态的变更引起了行为的变更,从外部看起来就好像这个对象对应的类发生...原创 2011-03-17 12:10:49 · 84 阅读 · 0 评论 -
23-21,解释器模式
1、解释器模式(Interpreter Pattern)是一种按照规定语法进行解析的方案,在现在的项目中使用很少。其定义如下:Given a language, define a representation for its grammar along with an interpreter that uses the representation to interpret sentences i...原创 2011-03-17 12:11:25 · 93 阅读 · 0 评论 -
23-22,享元模式
1、享元模式(Flyweight Pattern)是池技术的重要实现方法,其定义如下:Use sharing to support numbers of fine-grained objects efficiently(使用共享对象可有效地支持大量的细粒度的对象) 2、享元模式的角色名称 一、Flyweight-抽象享元角色 它简单的说就是一个产品的抽象类,同时定义出对象外部...原创 2011-03-17 12:12:23 · 83 阅读 · 0 评论 -
23-12,策略模式
1、策略模式原创 2011-03-17 11:29:36 · 69 阅读 · 0 评论 -
23-11,装饰模式
1、装饰模式(Decorator Pattern)是一种比较常见的模式,其定义如下:Attach additional responsibilities to an object dynamically keeping the same interface. Decorators provide a flexible alternative to subclassing for extending...原创 2011-03-17 11:29:03 · 62 阅读 · 0 评论 -
23-1,单例模式
单例模式要求在环境中只有一个实例。原创 2011-03-08 15:48:48 · 63 阅读 · 0 评论 -
23-2,工厂方法模式
1、定义一个用于创建对象的接口,让子类决定实例化哪一个类。工厂方法使一个雷的实例化延迟到其子类。原创 2011-03-08 15:52:17 · 54 阅读 · 0 评论 -
23-3,抽象工厂模式
1、为创建一组相关或者相互依赖的对象提供一个接口,而且无需指定它们的具体类。原创 2011-03-08 17:16:55 · 60 阅读 · 0 评论 -
23-4,模板方法模式
1、定义一个操作中的算法的框架,而将一些步骤延迟到子类中,是的子类可以不改变一个算法的结构即可重新定义该算法的某些特定步骤。 2、钩子方法。...原创 2011-03-14 14:36:47 · 63 阅读 · 0 评论 -
23-5,建造者模式
1、建造者模式也叫生成器模式,将一个复杂对象的构建和它的表示分离,使得同样的构建过程可以创建不同的表示。 2、四个角色: 一、Product产品类。 二、Builder抽象建造类 三、ConcreteBuilder具体构造类 四、Director导演类 ...原创 2011-03-14 16:46:25 · 67 阅读 · 0 评论 -
23-6,代理模式
1、代理模式原创 2011-03-17 11:26:01 · 56 阅读 · 0 评论 -
23-7,原型模式
1、原型模式原创 2011-03-17 11:26:44 · 67 阅读 · 0 评论 -
23-8,中介者模式
1、中介者模式:Define an object that encapsulates how a set of objects interact. Mediator promotes loose coupling by keeping objects form referring to each other explicitly. and it cets you vary their intera...原创 2011-03-17 11:27:31 · 55 阅读 · 0 评论 -
29-9,命令模式
1、命令模式原创 2011-03-17 11:28:02 · 58 阅读 · 0 评论 -
23-10,责任链模式
1、责任链模式原创 2011-03-17 11:28:35 · 57 阅读 · 0 评论 -
23-23,桥梁模式
1、桥梁模式(Bridge Pattern)也叫做桥接模式,是一个比较简单的模式,情定义如下:Decouple an abstraction form its implementation so that the two can vary independently.(讲抽象和实现解耦,使得两者可以独立的变化) 2、桥梁模式的四个角色 一、Abstraction-抽象化角色 ...原创 2011-03-17 12:12:55 · 77 阅读 · 0 评论