zoukankan      html  css  js  c++  java
  • 工厂模式的演变

    Simple Factory

    Is a class that can product various sub types of Product. (It is better than the Static Factory. When new types are added the base Product class does not need to be changed only the Simple Factory Class)


    也许可以将enum为参数应用反射可以使我们不用改变SimpleFactory中的代码。即可以只改变enum中的个数。

     Factory Method

    Contains one method to product one type of product related to its type.

    包含一个抽象类型的工厂类,并有若干个子工厂类实现该工厂。每个子工厂类分别创建各自的产品类。这也意味着,存在着抽象类型的工厂类关联着一个抽象的产品类。

    和Simple Factory不同的是,当增加新的产品时,Factory Method所要产生的修改体现了Open-Close原则。而Simple Factory对于这一变化却无法作到。 


    Abstract Factory

    Produces A Family of Types that are related. It is noticeably different than a Factory Method as it has more than one method of types it produces. 

    和工厂方法不同的是,Abstract Factory中的每个子工厂类创建是若干个不同的子产品类。

     

  • 相关阅读:
    STL
    Makefile
    配置pyqt5环境 for python3.4 on Linux Mint 17.1
    SELinux Policy Macros
    python爬虫
    python常用模块
    python中if __name__ == '__main__':
    Centos 7 .Net core后台守护进程Supervisor配置
    阅读Google Protocol Buffers 指南,整理pb语法
    Google Protocol Buffers 入门
  • 原文地址:https://www.cnblogs.com/malaikuangren/p/2438106.html
Copyright © 2011-2022 走看看