Difference between singleton and factory pattern

后端 未结 6 873
心在旅途
心在旅途 2020-12-07 09:41

I\'m new to design patterns and I cant really see a difference between this two patterns, both are creational patterns arent they? and what is the purpose of each pattern? t

6条回答
  •  醉话见心
    2020-12-07 10:00

    Singleton returns the same instance of class all the time, factory can create objects by instantiating various classes, or by using other allocation schemes such as an object pool. so singleton can be used in factory pattern

提交回复
热议问题