fWX228941 / project

all by myself
1 stars 0 forks source link

Design Pattern #27

Open fWX228941 opened 5 years ago

fWX228941 commented 5 years ago

Bridge pattern is about preferring composition over inheritance 一个具体对象拆分为两个维度的对象,以关联来取代继承,decouple an abstraction from its implementation so that the two can vary independently by providing a bridge structure between them. you have a proliferation of classes. Such a class hierarchy indicates the need for splitting an object into two parts. Rumbaugh uses the term "nested generalizations" to refer to such class hierarchies. 解耦,是结构型,不过最终用到客户手中就是创建型 we can configure an abstraction with an implementor object at run-time. 不同颜色的交通工具,一个是颜色,一个是交通工具 

《Bridge Pattern》  https://dzone.com/articles/bridge-design-pattern-in-java https://github.com/iluwatar/java-design-patterns/tree/master/bridge

fWX228941 commented 5 years ago

This simple interface to the complex subsystem is a facade. Most patterns, when applied, result in more and smaller classes. This makes the subsystem more reusable and easier to customize, 复杂提供提供简单统一的对外接口, Introduce a facade to decouple the subsystem from clients and other subsystems, thereby promoting subsystem independence and portability. 一个系统可以有多个外观类 If subsystems are dependent, then you can simplify the dependencies between them by making them communicate with each other solely through their facades. 结构型The people walking past the road can only see this glass face of the building. They do not know anything about it, the wiring, the pipes and other complexities. It hides all the complexities of the building and displays a friendly face. 楼门面,数据库 《Facade Pattern》 

fWX228941 commented 5 years ago

facadeA