Adapter 故名思意"适配器"类型,它主要的功能是改变一个类的方法使之符合特定的方法.实现Adapter有两种方式,一种是从类继承.在子类中加入新的方法.另一种就是将基类做为子类的一个参数,重新封装基类.
Bridge 的只要目的是将接口和类的实现分离,这类似于Adapter Pattern中的类适配.但是类适配模式的主要目的是将各个不同的类的接口统一,而Bridge的目的则是将接口和类的实现分离,在不改变类的接口的情况下,我们可以从新实现方法.
Composite 是一个组合变量的模式.它可以将复杂的类型和简单的类型组合,类似树的结构.在树中包含具有子节点或者叶子的节点,也有叶子节点.在树类型的编程中,我们经常需要根据节点的属性来判断节点的类型,然后做处理.而且不同的节点类型对其处理的方法也不尽相同.所以将所有的节点统一就可以减少客户端调用的复杂性.:) 如果节点的类型大部分是叶子类型节点,则我们可以将接口不统一,只是在取节点的时候利用instanceof来判断节点类型,来做相应的处理和调用.目的是为了Save space.
Decorator目的是不通过继承类的方式来改变类方法和接口的一种模式.就像是电视机与节目信号的关系.电视机我们可以有普通的彩色电视机和等离子 液晶等不同的类型,而电视节目的内容则只有一种,电视节目通过不同的电视机展现给观众的就是不一样的效果.在此电视机相当于就是Decorator模式的类.java.io.FilterInputStream就是一个典型的Decorator模式的类.
Adapter看起来只是为了修饰一个存在的类,你可以改变他的接口来适应新的应用,而Decorators则是为类增加了一些方法而已,而且针对的是实例,而不是该实例的类.而Composite则可以看成是一个操作列表对象的Decorators.
分享到:
相关推荐
Java高手真经 - Java Web系统设计与架构 源代码(一)设计模式 (3)设计模式样例(24个讲解样例程序) pattern/src/principle/liskovsubstitution//10.3.2里氏代换原则 pattern/src/creation/factorymethod //11.1...
JavaScript follows the prototypal inheritance pattern, unlike Java and C++ (which follow the inheritance pattern), there are some changes in writing data structures in JavaScript. The classical ...
pattern/src/structure/decorator //12.2装饰器模式 pattern/src/structure/proxy //12.3代理模式 pattern/src/structure/facade //12.4外观模式 pattern/src/structure/bridge //12.5桥接模式 pattern/src/...
pattern/src/structure/proxy //12.3代理模式 pattern/src/structure/facade //12.4外观模式 pattern/src/structure/bridge //12.5桥接模式 pattern/src/structure/composite //12.6组合模式 pattern/src/structure/...
pattern/src/structure/proxy //12.3代理模式 pattern/src/structure/facade //12.4外观模式 pattern/src/structure/bridge //12.5桥接模式 pattern/src/structure/composite //12.6组合模式 pattern/src/structure/...
pattern/src/structure/decorator //12.2装饰器模式 pattern/src/structure/proxy //12.3代理模式 pattern/src/structure/facade //12.4外观模式 pattern/src/structure/bridge //12.5桥接模式 pattern/src/...
java7 源码 coder-tools是程序员对一些新类库、新技术、新特性研究的笔记,为了让您更快更容易对这些新东西入手,时间久了可以达到温故而知新 jvm-library design-pattern 包含23种设计模式 structure-arithmetic ...
pattern/src/structure/proxy //12.3代理模式 pattern/src/structure/facade //12.4外观模式 pattern/src/structure/bridge //12.5桥接模式 pattern/src/structure/composite //12.6组合模式 pattern/src/structure/...
pattern/src/structure/proxy //12.3代理模式 pattern/src/structure/facade //12.4外观模式 pattern/src/structure/bridge //12.5桥接模式 pattern/src/structure/composite //12.6组合模式 pattern/src/structure/...
pattern/src/structure/proxy //12.3代理模式 pattern/src/structure/facade //12.4外观模式 pattern/src/structure/bridge //12.5桥接模式 pattern/src/structure/composite //12.6组合模式 pattern/src/structure/...
pattern/src/structure/decorator //12.2装饰器模式 pattern/src/structure/proxy //12.3代理模式 pattern/src/structure/facade //12.4外观模式 pattern/src/structure/bridge //12.5桥接模式 pattern/src/...
pattern/src/structure/proxy //12.3代理模式 pattern/src/structure/facade //12.4外观模式 pattern/src/structure/bridge //12.5桥接模式 pattern/src/structure/composite //12.6组合模式 pattern/src/structure/...
pattern/src/structure/decorator //12.2装饰器模式 pattern/src/structure/proxy //12.3代理模式 pattern/src/structure/facade //12.4外观模式 pattern/src/structure/bridge //12.5桥接模式 pattern/src/...
数据结构和算法--Java 所有算法均以Java实现(出于教育目的) 这些实现是出于学习目的。 这些实现的效率可能不如Java标准库。 表中的内容:: 搜索算法 排序算法 数据结构 堆 队列 链表 树 贪婪算法 练习题
工具 :wrench: 我用不同类型的工具构建了它: -Programming Language: Java-Build Tool: Maven-Design Pattern: Page Object Model-Structure: BDD (Cucumber and Gherkin)-Tags-Hooks-Backgrounds-Scenarios ...
本书大量采用uML的class Diagram(Static Structure Diagram)。书中的例子程序虽然都是用JaVa编写,但是本书所介绍的内容对于任何00语言的用户都适用,包括c++和c#。
pattern, unlike Java and C++ (which follow the inheritance pattern), there are some changes in writing data structures in JavaScript. The classical inheritance pattern allows inheritance by creating a...
The system uses the MVC design pattern, the program realizes the separation of the business logic, logic and presentation logic control. The system structure is clear, has good readability, ...
hesujin设计模式通过学习极客时间王争老师的设计模式之美运用相关的设计模式创建型模式(build_design_pattern)是将创建和使用代码解压缩结构型模式(structure_design_pattern)是将不同功能代码解压缩行为类型...