一.桥接模式简介(Brief Introduction) 桥接模式(Bridge Pattern),将抽象部分与它的实现部分分离,使的抽象和实现都可以独立地变化. Decouple an abstraction from its implementation so that the two can vary independently.. 什么是聚合/组合: 聚合(Aggregation),当对象A被加入到对象B中,成为对象B的组成部分时,对象B和对象A之间为聚合关系.聚合是关联关系的一种,是较…
桥接模式 Bridge Pattern 结构设计模式 定义: 分离抽象部分和实现部分,使他们独立运行. 避免使用继承导致系统类个数暴增,可以考虑桥接模式. 桥接模式将继承关系转化为关联关系,减少耦合,减少代码量. 例如: public interface Shape { public void bepaint(String color); } public abstract class Color { Shape shape; public void setShape(Shape shape)…