Design Patterns -- Bridge
2006-06-22 10:24
232 查看
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:
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:
相关文章推荐
- Bridge(Chapter 9 of Pro Objective-C Design Patterns for iOS)
- DesignPatterns_Bridge
- Design Patterns 5 : Bridge -- Independent variations
- Bridge模式 - 《Design patterns Explained》心得
- Core Design Patterns(3) Bridge 桥接模式
- MapReduce Design Patterns(chapter 2 (part 1))(二)
- MapReduce Design Patterns(chapter 3 (part 2))(六)
- MapReduce Design Patterns(chapter 5 (part 1))(九)
- 设计模式之单例模式 (Design patterns of the The singleton pattern)c#
- 装饰者模式——Head First Design Patterns
- Mobile UI Design Patterns: 10+ Sites for Inspiration
- 抽象工厂模式——Head First Design Patterns
- singletonclassDesign Patterns: Singleton Basics 设计模式:单例基础
- [必读免费新电子书]:JavaScript和jQuery基本设计模式(Essential JavaScript & jQuery Design Patterns For Beginners) 最后编辑:2010-11-16 18:15
- Patterns in network system design 之一
- Design Patterns 2 : Facade -- Simplification & Encapsulation
- Design_Patterns-Adapter
- Design Patterns for Distributed Non-Relational Databases
- How I explained Design Patterns to my wife: Part 1
- Prototype(Chapter 3 of Pro Objective-C Design Patterns for iOS)