摘要
针对传统建造者模式存在创建的产品数量单一、具体建造者与产品耦合度高等缺点,通过引入抽象工厂模式,提出一种改进的建造者模式。该模式通过具体工厂角色代替具体建造者来实现复杂对象组成部分的创建,达到与产品角色的解耦;在具体建造者中维护一个产品对象集合,以达到产品对象的多数量创建。分析了改进后建造者模式的UML类图关系与角色构成,并给出了核心实现代码,最后对该模式进行了应用效果分析。
For the shortcomings existing in traditional builders model of single products creation,specific builders and high coupling products, through introducing the abstract factory pattern, this paper puts forward an improved builder design pattern. The model through concrete factory role instead of the builders is to realize the complex object part of creation, to achieve the role of product decoupling;maintain a product in the concrete builders of a collection of objects, in order to achieve product object to create more quantity. An analysis is made of the improved builders of UML class diagram relation and role model, and an introduction is made of the core implementation code, finally an analysis is made of the application effect of this model.
出处
《咸阳师范学院学报》
2014年第6期43-46,共4页
Journal of Xianyang Normal University
基金
咸阳师范学院科研基金项目(12XSYK070)
关键词
设计模式
建造者模式
抽象工厂模式
复杂对象
design pattern
builder pattern
abstract factory pattern
complex object