<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

    主站蜘蛛池模板: 成人黄色免费网站| 菠萝菠萝蜜在线免费视频| 毛片免费观看的视频| 亚洲男人天堂av| 在线a人片天堂免费观看高清| 日韩一级片免费观看| 亚洲激情视频在线观看| 国产美女a做受大片免费| a级男女仿爱免费视频| 亚洲一线产区二线产区区| 亚洲日韩在线观看| 国产三级在线免费观看| 亚洲一区二区三区影院| 午夜国产精品免费观看| 免费一区二区三区在线视频| 亚洲黄色在线网站| 中文字幕无码成人免费视频| 国产高清视频免费在线观看 | 亚洲国产午夜精品理论片| 免费一级做a爰片性色毛片| 一级毛片在线免费看| 亚洲欧洲中文日产| 亚洲一区二区精品视频| 在线观看免费人成视频色| a级毛片无码免费真人久久| 亚洲国产aⅴ成人精品无吗| 亚洲视频中文字幕在线| 国内精品99亚洲免费高清| 成人a视频片在线观看免费| 日本一区午夜艳熟免费| 亚洲国产精品线观看不卡| 国产亚洲大尺度无码无码专线| 无码国产精品久久一区免费| 日韩免费视频一区二区| 亚洲AV无码精品蜜桃| 亚洲AV永久无码精品| 区三区激情福利综合中文字幕在线一区亚洲视频1 | 国产精品深夜福利免费观看 | 一级女人18毛片免费| 亚欧免费一级毛片| sihu国产精品永久免费|