Dedian  
-- 关注搜索引擎的开发
日历
<2006年4月>
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456
统计
  • 随笔 - 82
  • 文章 - 2
  • 评论 - 228
  • 引用 - 0

导航

常用链接

留言簿(8)

随笔分类(45)

随笔档案(82)

文章档案(2)

Java Spaces

搜索

  •  

积分与排名

  • 积分 - 64904
  • 排名 - 816

最新评论

阅读排行榜

评论排行榜

 
Purpose: Adapters are used to enable objects with different interfaces to communicate with each other which convert the interface of a class into another interface clients expect thus let classes work together without imcompatible interfaces problem.

Object Adapter:

-- use compositional technique
-- by composing interface B's instance within interface A (target interface, adapter) and implement interface A in terms of B's interface(adaptee). Interface A is Object Adapter which enables the client (the class or object to use Interface A) and the adaptee(Interface B) to be completely decoupled from each other.

Class Adapter:

-- use multiple inheritance
-- Notice that Java is not supporting true multiple inheritance, there must be one inheritance is from Java Interface(implementation) not Java class. So take above Object Adapter as example, if client want to access Interface B, the adpater Interface A will inherit from class(Class Adapter) which Client can access, and inherit the implementation of Interface B(Adaptee). So Interface A can have a funtion to call functions in Interface B, and so that Interface will not have an object of Interface B, that is the difference from Object Adapter method.

reference:
http://www.exciton.cs.rice.edu/JavaResources/DesignPatterns/adapter.htm

posted on 2006-04-19 20:37 Dedian 阅读(293) 评论(0)  编辑  收藏 所属分类: Design Patterns

只有注册用户登录后才能发表评论。


网站导航:
 
 
Copyright © Dedian Powered by: 博客园 模板提供:沪江博客