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

simple factory, factory method, abstract factory的更多相关文章

  1. Design Pattern ——Factory Method&Abstract Factory

    今天开始复习设计模式.设计模式相关的资料有很多,概念性的东西就画个图就可以了.把关注点放在例子上,设计模式还是要使用中才有感受. 从Factory Method&Abstract Factor ...

  2. 设计模式(一): abstract factory抽象工厂模式 -- 创建型模式

    1.定义 为创建一组相关或相互依赖的对象提供一个接口,而且无需指定他们的具体类. 2.适用场景 1.一个系统要独立于它的产品创建.组合和表示. 2.一个系统要由多个产品系列中的一个来配置. 3.当你要 ...

  3. Simple Factory vs. Factory Method vs. Abstract Factory【简单工厂,工厂方法以及抽象工厂的比较】

    I ran into a question on stackoverflow the other day that sort of shocked me. It was a piece of code ...

  4. "Simple Factory" vs "Factory Method" vs "Abstract Factory" vs "Reflect"

    ref: http://www.cnblogs.com/zhangchenliang/p/3700820.html 1. "Simple Factory" package torv ...

  5. C++设计模式 之 “对象创建”模式:Factory Method、Abstract Factory、Prototype、Builder

    part 0 “对象创建”模式 通过“对象创建” 模式绕开new,来避免对象创建(new)过程中所导致的紧耦合(依赖具体类),从而支持对象创建的稳定.它是接口抽象之后的第一步工作. 典型模式 Fact ...

  6. 抽象工厂(Abstract Factory),工厂方法(Factory Method),单例模式(Singleton Pattern)

    在谈工厂之前,先阐述一个观点:那就是在实际程序设计中,为了设计灵活的多态代码,代码中尽量不使用new去实例化一个对象,那么不使用new去实例化对象,剩下可用的方法就可以选择使用工厂方法,原型复制等去实 ...

  7. 面向对象设计——抽象工厂(Abstract Factory)模式

    定义 提供一个创建一系列相关或者相互依赖对象的接口,而无需指定它们具体的类.抽象工厂允许客户使用抽象的接口来创建一组相关的产品,而不需要知道或关心实际产出的具体产品是什么.这样一来,客户就能从具体的产 ...

  8. PHP设计模式(三)抽象工厂模式(Abstract Factory)

    一.什么是抽象工厂模式 抽象工厂模式的用意为:给客户端提供一个接口,可以创建多个产品族中的产品对象 ,而且使用抽象工厂模式还要满足以下条件: 系统中有多个产品族,而系统一次只可能消费其中一族产品. 同 ...

  9. [Design Patterns] 01. Creational Patterns - Abstract Factory

    设计模式是一套被反复使用.多数人知晓的.经过分类编目的.代码设计经验的总结,使用设计模式的目的是提高代码的可重用性,让代码更容易被他人理解,并保证代码可靠性.它是代码编制真正实现工程化. 四个关键元素 ...

随机推荐

  1. 类型自动转换引起的误解——QString可以赋值数字1,也能直接与0比较,真是昏倒!

    看以下代码,能编译通过: void MainWindow::on_pushButton_clicked() { QString str = "test"; ) { QMessage ...

  2. PYQT4 + Python2.6 + eric4-4.2.2a的安装全过程

    PYQT4 + Python2.6 + eric4-4.2.2a的安装全过程 - beike - ITeye技术网站 PYQT4 + Python2.6 + eric4-4.2.2a的安装全过程 博客 ...

  3. 多项式相乘(C语言)

    //两个多项式的系数f分别存在x[]和y[]中,下标即为次数,*Max表示本多项式最高次数 int MX_double( double x[], int xMax, double y[], int y ...

  4. A Game of Thrones(18) - Catelyn

    “We will make King’s Landing within the hour.” Catelyn turned away from the rail and forced herself ...

  5. HDU 3613 Best Reward 正反两次扩展KMP

    题目来源:HDU 3613 Best Reward 题意:每一个字母相应一个权值 将给你的字符串分成两部分 假设一部分是回文 这部分的值就是每一个字母的权值之和 求一种分法使得2部分的和最大 思路:考 ...

  6. 从零开始,使用python快速开发web站点(1)

    环境:ubuntu 12.04 python版本:  2.73 ok,首先,既然是从零开始,我们需要的是一台可以运行的python的计算机环境,并且假设你已经安装好了python, (ubuntu 或 ...

  7. URAL1523(dp+树状数组)

    题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=41224#problem/B 分析:可以设dp[i][j]表示以i结尾长度为j的 ...

  8. 前端控件之Jquery datetimepicker的使用总结

    效果图 在介绍jquery datetimepicker的使用方法前,我们先来看一下它的实现效果图,这样以便让你更快地了解它是否是你所需要的. 下面我截了四张常用的效果图(截取自http://xdso ...

  9. 通过 Jersey Http请求头,Http响应头,客户端 API 调用 REST 风格的 Web 服务

    原地址:http://blog.csdn.net/li575098618/article/details/47853263 Jersey 1.0 是一个开源的.可以用于生产环境的 JAX-RS(RES ...

  10. C++:抽象基类和纯虚函数的理解

    转载地址:http://blog.csdn.net/acs713/article/details/7352440 抽象类是一种特殊的类,它是为了抽象和设计的目的为建立的,它处于继承层次结构的较上层. ...