六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 41|回复: 0

Design Patterns -

[复制链接]

升级  13%

73

主题

73

主题

73

主题

举人

Rank: 3Rank: 3

积分
239
 楼主| 发表于 2013-1-27 05:06:52 | 显示全部楼层 |阅读模式
1. The intent of the BRIDGE pattern is to decouple an abstraction (a  class that relies on a set of abstarct operations, GoF Design Patterns)  from the implementation of its abstract operation, so that the abstraction and its implementation can vary independently.
2. A Bridge structure moves the abstract operations that an abstraction relies on into a separate interface, pic:

Implementor contains the abstract operations seperated from Abstraction, and after seperation Abstraction  is concrete.
3. A common example of Bridge occurs in drivers using. An application that uses a driver is an abstraction -- the choice of driver determines what happens when the application runs.
4. Steps to refactor a hierarchy with an abstract class at lits top into a bridge:
a. Move the abstract operation in the superclass into an interface.
b.Define implementation classes that provide different implementations of the interface.
c. Redefine the remaining operations in the abstract class as operations on an instance of the new interface. (The remaining operations usually uses the functions in the interface).
5. Another example of Bridge:
ori:

sec:

after refactor:

 
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表