Bridge(Chapter 9 of Pro Objective-C Design Patterns for iOS)
2012-04-20 15:28
711 查看
Abstraction is the parent interface that defines the high-level abstraction interface used by clients. It has a reference to an instance of Implementor, which defines the interface for implementation classes. This interface doesn’t need to correspond to Abstraction’s interface; in fact, they can be quite different. The Implementor’s interface provides primitive operations, and Abstraction’s higher-level operations are based on these primitives. When a client sends an operation message to an instance of Abstraction, the method sends an operationImp message to imp. An actual underlying ConcreteImplementator (A or B) will respond to that and pick up the task. So if you want to add new ConcreteImplementators to the system, all you need to do is to create a new implementing class for Implementor that responds to the operationImp message and perform any specific operations there. That won’t affect anything on the Abstraction side, though. Likewise, if you want to make changes to the interface of Abstraction or create more refined Abstraction classes, you can do so without affecting the other side of the bridge as well.
相关文章推荐
- Prototype(Chapter 3 of Pro Objective-C Design Patterns for iOS)
- Observer(Chapter 12 of Pro Objective-C Design Patterns for iOS)
- Memento(Chapter 23 of Pro Objective-C Design Patterns for iOS)
- Singleton(Chapter 7 of Pro Objective-C Design Patterns for iOS)
- Iterator(Chapter 14 of Pro Objective-C Design Patterns for iOS)
- Strategy(Chapter 19 of Pro Objective-C Design Patterns for iOS)
- Factory Method(Chapter 4 of Pro Objective-C Design Patterns for iOS)
- Mediator(Chapter 11 of Pro Objective-C Design Patterns for iOS)
- Chain of Responsibility(Chapter 17 of Pro Objective-C Design Patterns for iOS)
- Abstract Factory(Chapter 5 of Pro Objective-C Design Patterns for iOS)
- Adapter(Chapter 8 of Pro Objective-C Design Patterns for iOS)
- Façade(Chapter 10 of Pro Objective-C Design Patterns for iOS)
- Decorator(Chapter 16 of Pro Objective-C Design Patterns for iOS)
- Builder(Chapter 6 of Pro Objective-C Design Patterns for iOS)
- Visitor(Chapter 15 of Pro Objective-C Design Patterns for iOS)
- Flyweight(Chapter 21 of Pro Objective-C Design Patterns for iOS)
- Template Method(Chapter 18 of Pro Objective-C Design Patterns for iOS)
- Composite(Chapter 13 of Pro Objective-C Design Patterns for iOS)
- Command(Chapter 20 of Pro Objective-C Design Patterns for iOS)
- Proxy(Chapter 22 of Pro Objective-C Design Patterns for iOS)