官术网_书友最值得收藏!

The Bridge design pattern

Decouple an abstraction from its implementation so that the two can vary independently
- GoF Design Patterns: Elements of Reusable Object-Oriented Software

In software engineering, one of the most popular notions is preferred composition over inheritance. Bridge design pattern promotes this popular notion. Similar to the adapter pattern, this pattern also comes under the structural design pattern family of the GoF Design Pattern. The approach of the Bridge pattern is to decouple an abstraction used by the client code from its implementation; that means it separates the abstraction and its implementation in to separate class hierarchies. And also, Bridge pattern prefers composition over inheritance because inheritance isn't always flexible and it breaks the encapsulation, so any change made in the implementer affects the abstraction used by the client code.

The bridge provides a way to communicate between two different independent components in software development, and a bridge structure provides you with a way to decouple the abstract class and the implementer class. So any change made in either the implementation class or the implementer (that is, the interface) doesn't affect the abstract class or its refined abstraction class. It makes this possible by using composition between the interface and the abstraction. Bridge pattern uses an interface as a bridge between the concrete classes of an abstract class and implementing classes of that interface. You can make changes in both types of class without any impact on the client code.

主站蜘蛛池模板: 开封县| 甘南县| 法库县| 大安市| 宜宾县| 突泉县| 璧山县| 云龙县| 建平县| 贺州市| 贡嘎县| 无极县| 永泰县| 洛阳市| 德保县| 夏津县| 高安市| 全椒县| 新民市| 依安县| 闸北区| 涞源县| 乌兰浩特市| 博湖县| 荃湾区| 灵寿县| 清河县| 刚察县| 乃东县| 将乐县| 宽城| 佛山市| 太原市| 郧西县| 广丰县| 鹤壁市| 酉阳| 四子王旗| 定日县| 松江区| 九龙县|