What are the practical use differences between Flyweight vs Singleton patterns?

后端 未结 7 475
攒了一身酷
攒了一身酷 2021-02-04 01:50

The two pattern seems to achieve the same thing. What are the different use cases in real world? Thanks

7条回答
  •  深忆病人
    2021-02-04 02:21

    They are two entirely different "pattern Types". Singleton is a "CREATION" pattern. Creation patterns are higher order common "Object creation" methodologies. On the other hand, Flyweight is a "Structural pattern". Structural patterns have to do more with interfaces and implementation rather than "object creation". Another easier way to describe the differences is the the first pattern type "Creation patterns" are more noun based. The second "Structural pattern" types are more verb based.

提交回复
热议问题