Dedian  
          -- 關注搜索引擎的開發
          日歷
          <2006年4月>
          2627282930311
          2345678
          9101112131415
          16171819202122
          23242526272829
          30123456
          統計
          • 隨筆 - 82
          • 文章 - 2
          • 評論 - 228
          • 引用 - 0

          導航

          常用鏈接

          留言簿(8)

          隨筆分類(45)

          隨筆檔案(82)

          文章檔案(2)

          Java Spaces

          搜索

          •  

          積分與排名

          • 積分 - 65900
          • 排名 - 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 閱讀(300) 評論(0)  編輯  收藏 所屬分類: Design Patterns
           
          Copyright © Dedian Powered by: 博客園 模板提供:滬江博客
          主站蜘蛛池模板: 榆中县| 广德县| 合阳县| 仙游县| 贵阳市| 鄂尔多斯市| 托克托县| 大渡口区| 沂源县| 张家界市| 抚松县| 肃宁县| 洪湖市| 从化市| 龙里县| 东乌珠穆沁旗| 钟山县| 个旧市| 环江| 峨眉山市| 淮滨县| 什邡市| 巴南区| 贡觉县| 邛崃市| 钟祥市| 固安县| 周至县| 乌什县| 叙永县| 永泰县| 定结县| 长岭县| 广东省| 滦平县| 翼城县| 宁乡县| 屯昌县| 凤山县| 乐都县| 谷城县|