<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

    主站蜘蛛池模板: 国产免费内射又粗又爽密桃视频 | 免费人成视频在线观看不卡| 亚洲国产精品免费在线观看| 91精品国产免费网站| 亚洲AV无码1区2区久久| 久久久久久成人毛片免费看| 亚洲AV无码一区二区三区DV| 99免费在线观看视频| 亚洲黄色免费电影| 国产美女在线精品免费观看| 一本色道久久88—综合亚洲精品 | 国产小视频免费观看| 无码色偷偷亚洲国内自拍| 国产在线观看免费完整版中文版| 国产精品亚洲天堂| 亚洲?V乱码久久精品蜜桃 | 日本精品久久久久久久久免费| 国产成人免费永久播放视频平台| 免费看美女午夜大片| 亚洲一区视频在线播放| 大地资源在线资源免费观看 | 亚洲大片在线观看| 午夜国产精品免费观看| 亚洲暴爽av人人爽日日碰| 全亚洲最新黄色特级网站| 国产好大好硬好爽免费不卡| 亚洲成a人片在线看| 亚洲Av无码乱码在线观看性色| 中文字幕免费观看视频| 亚洲日韩乱码久久久久久| 国产成人精品免费视频软件| a成人毛片免费观看| 亚洲三级在线观看| 亚洲一区无码精品色| 国拍在线精品视频免费观看| 乱淫片免费影院观看| 亚洲精品视频在线观看免费| 国产亚洲精品免费| 日本片免费观看一区二区| 男女超爽视频免费播放| 亚洲精品视频在线免费|