Design Patterns -- Bridge

原创 2006年06月22日 10:24:00

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:



after refactor:


Head First Design Patterns影印版和中文版

深入浅出设计模式(影印版) First设计模式(中文版)http://www.oreill...
  • ddkiller
  • ddkiller
  • 2007年10月15日 08:42
  • 800

设计模式 - Design Patterns

设计模式四人组 GoF(“四人帮”,又称Gang of Four,即Erich Gamma、Richard Helm、Ralph Johnson和John Vlissides四人)1. 起源Go...
  • u010297957
  • u010297957
  • 2016年03月29日 23:20
  • 1094

Design Patterns: Solidify Your C# Application Architecture with Design Patterns中文版(上篇)

Design Patterns: Solidify Your C# Application Architecture with Design Patterns中文版(上篇)作者:Samir Bajaj...
  • optimizer
  • optimizer
  • 2002年01月09日 10:43
  • 844

Design Patterns in Android:目录纲要

《Design Patterns in Android》(设计模式Android篇),旨在总结自己作为一名Android开发者,在摸索设计模式的过程中爬过的坑,因为很多设计模式的博文,书籍都是针对Ja...
  • Xiong_IT
  • Xiong_IT
  • 2017年01月16日 21:15
  • 1315

Applying Domain-Driven Design and Patterns(ADDDP) With examples in C# and .NET

Applying Domain-Driven Design and Patterns(ADDDP) With examples in C# and .NET是在Martin Fowler的PoE...
  • shanyou
  • shanyou
  • 2007年07月06日 21:08
  • 657

【读书】《Node.js Design Patterns》1.1——Node.js哲学

  • sinat_26054677
  • sinat_26054677
  • 2015年02月17日 15:43
  • 857

java设计模式(Design Patterns)

设计模式(Design Patterns)                                   ——可复用面向对象软件的基础 设计模式(Design pattern)是一套被反复使用、...
  • zhihui1017
  • zhihui1017
  • 2015年11月09日 10:54
  • 1470

C++版的Head First Design Pattern

       前 些天从sourceforge上down下一个C++版的Head First Design Pattern,一直都没有仔细看过,也不知道HeadFirstDesignPattern是一...
  • iinel
  • iinel
  • 2007年11月16日 10:13
  • 1601

Design Principles and Design Patterns(设计原则与设计模式) -Robert C. Martin

What is software architecture? The answer is multitiered. At the highest level, there are the archit...
  • zhaohuabing
  • zhaohuabing
  • 2011年07月24日 12:13
  • 1414

Design Patterns in Swift:单例模式(中)

转自: 如有侵犯,请来信oiken@qq...
  • oiken
  • oiken
  • 2016年07月02日 14:55
  • 343
您举报文章:Design Patterns -- Bridge