需求:需要组装复杂结构的实例 代码清单: Builder 接口: public abstract class Builder { public abstract void makeTitle(String title); public abstract void makeString(String str); public abstract void makeItems(String[] itens); public abstract void close(); } 实现1: public cl…
1.什么是装饰器模式? Attach additional responsibilities to an object dynamically keeping the same interface.Decorators provide a flexible alternative to subclassing for extending functionality. 装饰器模式(Decorator Pattern):动态的给一个对象添加额外的职责,就增加功能来说, 装饰模式相比生成子类更为灵活.…