分类3 生成实例
2019-05-09 10:15:27 0 举报
设计模式
作者其他创作
大纲/内容
ConcreteBuilder1
buildHead()buildBody()buildFoot()
ConcretePrototype
clone()
ConcreteBuilder2
Singleton
- Singleton instance;
- Singleton();+ getInstance();+ method();
调用实例:Builder builder = new ConcreteBuilder1();Director dir = new Director();dir.setBuilder(builder);dir.build();builder.getProduct();
director 不能直接返回 product ? 怕耦合?
Director
Builder builder
build() { builder.buildHead(); builder.buildBody(); builder.buildFoot();}
Prototype
builder 建造模式
Builder
Product product
buildHead()buildBody()buildFoot()getProduct()
public class Director { private Builder builder; public void build (){ builder.buildHead(); builder.buildBody(); builder.buildFoot(); }}
调用示例:Singleton.getInstance().method();
singleton 单例模式
prototype 原型模式
Product
0 条评论
下一页