In simplest terms, what is a factory?

后端 未结 6 1528
南方客
南方客 2020-11-30 05:57

What is a factory and why would I want to use one?

6条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-30 06:05

    Factory is an object for creating other objects.

    It creates objects without exposing the instantiation logic to the client.

    Use this pattern when you don't want to expose object instantiation logic to the client/caller

    Related posts:

    Design Patterns: Factory vs Factory method vs Abstract Factory

    What is the basic difference between the Factory and Abstract Factory Patterns?

提交回复
热议问题