适配器模式adapter
来源:互联网 发布:校验md5码软件 编辑:程序博客网 时间:2024/04/29 20:34
类适配器UML
直接实现Target接口即可
对象适配器UML
Adapter 继承Target,组合Aaptee
由于编程原则,多用组合少用继承;对抽象编程,不对具体编程;
因此大多数情况下,为了后续程序的灵活性,我们倾向于使用对象适配器。
下述代码也是对象适配器的示例:
show code
在早期的java中集合collection都实现了接口elements()方法,该方法返回一个Enumeration枚举对象
Enumeration接口有两个方法hasMoreEelement()和nextElement()
但是后来集合类型开始使用Iterator(迭代器)接口来遍历集合内部的对象,Iterator接口有三个方法hasNext()、next()和remove()
为了使新旧代码兼容,我们需要把老的Enumeration适配到Iterator。
0 0
- Adapter模式 适配器模式
- 适配器模式(Adapter)
- 适配器模式(Adapter)
- 适配器(Adapter)模式
- 适配器模式(Adapter Pattern)
- ADAPTER(适配器)模式
- 适配器模式(adapter)
- Adapter适配器模式
- 适配器(Adapter)模式
- 适配器模式(Adapter Pattern)
- Adapter(适配器)模式
- 适配器模式(adapter)
- 适配器模式(Adapter)
- 适配器模式(Adapter)
- 适配器模式(Adapter)
- 适配器模式 Adapter Pattern
- Adapter 适配器模式
- 适配器模式(Adapter)
- uva 11400 Lighting System Design dp
- 快速排序(二)
- 快速找到单链表的中间节点
- 窗口有关算法题目
- Zookeeper学习
- 适配器模式adapter
- Access denied for user 'root'@'localhost' (using password:YES) 解决方案
- [algorithm]2月29日
- SDUST SingleTest A(15.4.3)
- myeclipse10 js报错 jslib报错
- 根据首字母查找单词
- P122第21题
- UIView
- (7-2)hive参数配置使用