设计模式--创建模式--建造模式--java
来源:互联网 发布:音效控制软件 编辑:程序博客网 时间:2024/06/07 00:25
intent
•Separate the construction of a complex object from itsrepresentation so that the same construction process can create differentrepresentations .
•将构建和表示分离,使同样的构建过程可以创建不同的表示。
UML
Applicability
•the algorithm for creating a complex object should beindependent of the parts that make up the object and how they're assembled.
•创建复杂的对象的算法应该独立于组装部分和他们如何装配的。
•the construction process must allow differentrepresentations for the object that's constructed.
•构造的过程要求创建出来的对象有不同的表示。
Consequences
•Itlets you vary a product's internal representation
•使得产品内部表示可变。
•Itisolates code for construction and representation.
•分离构建代码和表示代码。
•Itgives you finer control over the construction process.
•使得构建过程更出色,更灵活。
example-StringBuilder
/** * 在使用StringBuilder端,实际上具有Client和Director角色。 * @author changsheng * */public class ClientDirector {public static void main(String[] args) {StringBuilder sb = new StringBuilder();/** * Director可以随意指导Builder来构造出不同的表示。 */sb.append(8);sb.append(27);sb.append("chang");sb.append("sheng");sb.append(2012);/** * 等价于Builder的getResult方法。 */String result = sb.toString();System.out.println(result);}}
所有实现此接口java.lang.Appendable,的都使用了BuilderPattern。
http://www.cnitblog.com/sugar/archive/2006/02/22/6808.html
- 设计模式--创建模式--建造模式--java
- java设计模式【创建模式】之建造(Bulider)模式
- JAVA设计模式创建型模式之建造模式
- java 设计模式-创建模式之建造者模式
- java-设计模式-创建模式-建造者模式builder
- Java设计模式之创建型模式--建造者模式
- 设计模式 创建模式之建造模式
- Java设计模式_(创建型)_建造者模式
- 创建型设计模式-建造者模式
- 设计模式/建造模式
- 设计模式:建造模式
- 设计模式:建造模式
- 设计模式--建造模式
- 设计模式-建造模式
- 设计模式-建造模式
- 【JavaScript设计模式】创建型设计模式--建造者模式
- Java的建造设计模式
- JAVA-建造者设计模式
- Proj.Net架构设计分析
- ANDROID 实现选择文件对话框
- 单链表反转
- js数组与 json 的区别
- 测试工具
- 设计模式--创建模式--建造模式--java
- jetty配置
- List 语言:set和setq差别
- java反射详解
- Gsensor/Gyro数据滤波算法思考
- 文件句柄
- js跨域请求,并控制js执行顺序
- myeclipse下Java工程不能被编译
- group by,having,order by的用法