<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    weidagang2046的專欄

    物格而后知致
    隨筆 - 8, 文章 - 409, 評論 - 101, 引用 - 0
    數(shù)據(jù)加載中……

    Adapter Design Pattern

    Note:  Do not confuse the abstract concept of an "interface" with the Java "interface" type in the following discussion!  

    Adapters are used to enable objects with different interfaces to communicate with each other.

    Adapters come in two flavors, object adapters and class adapters.  These two methods embody the difference between the use of inheritance and composition to solve problems.

    Object Adapters

    Object adapters use a compositional technique to adapt one interface to another.    The adapter inherits the target interface that the client expects to see, while it holds an instance the adaptee.   When the client calls the request() method on its target object (the adapter), the request is translated into the corresponding specific request on the adaptee.

    Object adapters enable the client and the adaptee to be completely decoupled from eachother.   Only the adapter knows about both of them.

    Class Adapters

    Class adapters use multiple inheritance to achieve their goals.   As in the object adapter, the class adapter inherits the interface of the client's target.   However, it also inherits the interface of the adaptee as well.   Since Java does not support true multiple inheritance, this means that one of the interfaces must be inherited from a Java Interface type.   Note that either or both of the target or adaptee interfaces could be an Java Interfaces.   The request to the target is simply rerouted to the specific request that was inherited fro the adaptee interface.

    Note that class adapters have a problem with name conflicts if methods of the same signature exist on both the target and the adaptee.  Note that just because two objects have methods that have the same signature (syntax), it does not guarantee that the two methods have the same meaning or behavior (sematics).    That is, the two methods do not necessarily map directly to each other.   Object adapters do not have this problem.

    Class adapters are simpler than object adapters in that they involve fewer classes and are useful if total decoupling of the client and adaptee is not needed.

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

    posted on 2006-02-26 22:46 weidagang2046 閱讀(223) 評論(0)  編輯  收藏 所屬分類: Java

    主站蜘蛛池模板: 野花高清在线观看免费完整版中文 | 日韩av无码成人无码免费| 国产精品亚洲精品日韩已满| 深夜久久AAAAA级毛片免费看| 女人18毛片特级一级免费视频| 国产成人亚洲合集青青草原精品| 久久精品国产免费观看| 亚洲精品在线网站| 91视频国产免费| 亚洲日韩看片无码电影| 免费的涩涩视频在线播放| 亚洲AV无码一区二区三区鸳鸯影院| 浮力影院第一页小视频国产在线观看免费 | 国产精品深夜福利免费观看| 亚洲综合精品伊人久久| 香蕉视频在线观看免费国产婷婷 | 免费一看一级毛片人| 一级毛片高清免费播放| 久久精品国产精品亚洲人人 | 成人免费毛片视频| 午夜在线亚洲男人午在线| 亚洲成a人片在线观看国产| aa毛片免费全部播放完整| 亚洲AV无码一区二区二三区入口 | 亚洲专区中文字幕| 国产福利免费观看| yellow视频免费看| 久久亚洲精品成人AV| 国产卡二卡三卡四卡免费网址 | 亚洲精品国自产拍在线观看| 巨胸狂喷奶水视频www网站免费| 无码欧精品亚洲日韩一区| 野花高清在线观看免费3中文 | 亚洲国产综合在线| 国产精品色午夜免费视频 | 国内精自视频品线六区免费| 亚洲精品无码人妻无码| 亚洲日韩精品无码一区二区三区| 91精品成人免费国产片| 无套内射无矿码免费看黄| 亚洲日本中文字幕区|