您的位置:首页 > 其它

simple factory, factory method, abstract factory

2014-09-17 19:17 447 查看

simple factory



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



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



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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐