simple factory, factory method, abstract factory

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

转载于:https://www.cnblogs.com/williamwood/p/3977870.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值