<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
    數據加載中……

    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 閱讀(224) 評論(0)  編輯  收藏 所屬分類: Java

    主站蜘蛛池模板: 1000部羞羞禁止免费观看视频| 一本久久免费视频| 亚洲欧洲日产国码无码网站| 在线亚洲v日韩v| 在线播放免费人成毛片乱码| 女人被弄到高潮的免费视频| 亚洲人成网站18禁止久久影院| 四虎国产精品成人免费久久| 免费人成在线观看视频播放| 羞羞视频在线观看免费| 精品亚洲一区二区三区在线观看| 国产日韩AV免费无码一区二区| 亚洲第一中文字幕| 曰韩无码AV片免费播放不卡 | 国产激情免费视频在线观看 | 亚洲人成网亚洲欧洲无码| 女人毛片a级大学毛片免费| 亚洲av永久无码一区二区三区| eeuss影院www天堂免费| 亚洲日韩v无码中文字幕| 亚洲视频在线观看免费| 亚洲国产精品专区在线观看| 一级一级毛片免费播放| 亚洲国产二区三区久久| 最近中文字幕免费mv视频8| 国产午夜亚洲精品不卡电影| 亚洲精品国产精品乱码视色| 久视频精品免费观看99| 国产尤物在线视精品在亚洲| 国产亚洲av片在线观看播放| 国拍在线精品视频免费观看 | 亚洲精品无码aⅴ中文字幕蜜桃| 全部免费毛片免费播放| 国色精品va在线观看免费视频| 亚洲欧洲日本精品| 免费一看一级毛片全播放| 黄网站免费在线观看| 成人亚洲国产va天堂| 精品成在人线AV无码免费看| 亚洲精品高清视频| 精品久久久久久久免费人妻|