码迷,mamicode.com
首页 > 其他好文 > 详细

simple factory, factory method, abstract factory

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

标签:blog   http   io   ar   2014   cti   log   on   c   

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

标签:blog   http   io   ar   2014   cti   log   on   c   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!