您的位置:首页 > 移动开发 > Objective-C

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.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: