Ray's playground

 

Bridge(Chapter 9 of Pro Objective-C Design Patterns for iOS)

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.

posted on 2012-04-20 15:28  Ray Z  阅读(236)  评论(0编辑  收藏  举报

导航