首页 > 其他 > 详细

simple factory, factory method, abstract factory

时间:2014-09-17 20:25:32      阅读:341      评论:0      收藏:0      [点我收藏+]

simple factory

bubuko.com,布布扣

good:
1 devide implementation and initialization
2 use config file can make system more flexible (reflection)

bad:
1 all initialization work in factory. when the logic is complex or too many products, the factory will be too complex.
hard to maintain.when can, the reflection can solve the issue of too many products.

2 extention not easy. when we want to add new product, the existing souce code of factory class should be modified.


when to use:
1 the factory does not have many products.
2 client does not care the details of the initialization

factory method

bubuko.com,布布扣

good:
1 factory can decide which product to create. The poli allow us not to modify client code when we want to add new product

bad:
1 system is complex.new factory class added.


abstract factory

bubuko.com,布布扣

good:
1 easy to add new products
2 add all products related at one time

bad:
1 very hard to add new hiracy of product

simple factory, factory method, abstract factory

原文:http://www.cnblogs.com/williamwood/p/3977870.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!