When to use factory patterns?

ⅰ亾dé卋堺 提交于 2019-12-19 07:13:29

问题


What is this factory all about and what are the advantages of using factory patterns? Does it give a plugable architecture? Why it is called "Factory"?


回答1:


It is factory since it is actually "Manufacturing" (Create) an object.

There's actually two kind of factory pattern defined by GoF:

  1. Factory Method
  2. Abstract Factory

Basically both of them tries to decouple the calling client from knowing the actual concrete implementation of the class/interface.




回答2:


You can find all you need by reading this PDF article



来源:https://stackoverflow.com/questions/4067271/when-to-use-factory-patterns

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!