The two pattern seems to achieve the same thing. What are the different use cases in real world? Thanks
The flyweight structual pattern essentially removes duplication of objects needed to achieve a certain goal. For example, imagine you were typing an essay (or maybe a post on stack overflow), which is ultimately comprised of the same 26 letters in the (English) alphabet, repeated many times. Would it be more efficient to have 1000 separate objects each representing the letter 'E', or have one single object representing the letter 'E', referenced 1000 times? (Hint, it would generally be the latter)
How the creation of each of the objects (ie. 26 letters) is implemented is a separate concern, however is commonly achieved with a factory method (a creational pattern) that utilizes "singleton like" characteristics.
Is this done through a fully-fledged singleton object, or just a private variable that only the factory method can access? May or may not be. But either way, the singleton pattern is a creational pattern, describing ways to have only a single instance of an object in existence at any given point in time, and is not concerned with specific use cases such as "removing duplication of objects needed to achieve a certain goal".