When to use factory patterns?

前端 未结 2 1638
旧时难觅i
旧时难觅i 2021-01-12 19:07

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\"?

相关标签:
2条回答
  • 2021-01-12 19:19

    You can find all you need by reading this PDF article

    0 讨论(0)
  • 2021-01-12 19:24

    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.

    0 讨论(0)
提交回复
热议问题