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:
- Factory Method
- 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