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

    主站蜘蛛池模板: 亚洲va久久久久| 国产亚洲精品资在线| 免费精品国产自产拍在| 日本免费一区二区在线观看| 一区二区三区福利视频免费观看| 国产免费网站看v片在线| 国产99久久久国产精免费| 国产精品99爱免费视频| 中文在线日本免费永久18近| 国产在线国偷精品免费看| 日本道免费精品一区二区| 免费精品99久久国产综合精品| 久久国产乱子伦精品免费强| 无码人妻AV免费一区二区三区| 久久国产色AV免费观看| 日韩免费一区二区三区在线播放| 国产精品免费观看久久| 日本免费的一级v一片| 亚洲国产成人久久精品99| 丝袜熟女国偷自产中文字幕亚洲| 亚洲啪啪综合AV一区| 亚洲国产人成网站在线电影动漫 | 日韩在线永久免费播放| 巨波霸乳在线永久免费视频| 97在线观免费视频观看| 永久免费AV无码网站在线观看| 免费一级毛片免费播放| 亚洲精品无码专区久久同性男| 亚洲日韩精品无码一区二区三区| 亚洲短视频男人的影院| 亚洲中文久久精品无码1| 无码亚洲成a人在线观看| WWW国产成人免费观看视频| 日韩精品人妻系列无码专区免费 | 国产免费牲交视频免费播放| 一区二区免费视频| 四虎免费大片aⅴ入口| 亚洲国产专区一区| 亚洲三级电影网址| 亚洲人成欧美中文字幕| 精品97国产免费人成视频|