[模式之集思广义] Adapter Pattern
来源:互联网 发布:淘宝怎么设置价格区间 编辑:程序博客网 时间:2024/06/03 00:04
1. Concept: 将一个类的接口转换成客户希望的另外一个接口。Adapter模式使得原本由于接口不兼容而不能一起工作的那些类可以一起工作。(GoF)
Convert the interface of a class into another interface clients expect. Adapter lets classes work together that couldn't otherwise because of incompatible interfaces.
2.
http://blog.csdn.net/surprisesdu/article/details/606148
一、 类的适配器模式
/**
* 客户端类
* @author suki
*/
public class Client {
public static void main(String[] args) {
Adaptee adaptee = new Adaptee();
Target target = new Adapter();
target.sampleOperation1();
}
}
二、 对象的适配器模式
/**
* 客户端类
* @author suki
*/
public class Client {
public static void main(String[] args) {
Adaptee adaptee = new Adaptee();
Target target = new Adapter(adaptee);
target.sampleOperation1();
}
}
3. 优先使用组合 而不是继承 ,所以object adapter要优于class adapter
- [模式之集思广义] Adapter Pattern
- [模式之集思广义] Builder Pattern
- [模式之集思广义] Prototype pattern
- 设计模式之适配器模式(Adapter Pattern)
- 设计模式之适配器模式--- Pattern Adapter
- Java之适配器模式(Adapter Pattern)
- Java之适配器模式(Adapter Pattern)
- 适配器模式(Adapter Pattern)
- 适配器模式(Adapter Pattern)
- 适配器模式 Adapter Pattern
- 适配器模式(Adapter Pattern)
- 适配器模式(Adapter Pattern)
- 适配器模式-Adapter Pattern
- 适配器模式 Adapter Pattern
- 适配器模式--Adapter Pattern
- 适配器模式(Adapter Pattern)
- 适配器模式(Adapter Pattern)
- 适配器模式【ADAPTER PATTERN 】
- 怎么打蝴蝶结
- smarty商品分页
- nand flash结构以及读写分析——写的比较经典
- vs2010中的ipch文件夹和sdf文件
- Linux启动过程简介
- [模式之集思广义] Adapter Pattern
- Flash Builder显示swf文件
- 职场不能说的秘密
- shell取日期串
- c/c++内存操作函数 是否初始化
- C++11中值得关注的几大变化
- test
- ubuntu环境搭建得错误处理
- Xmemcached用户指南