The two pattern seems to achieve the same thing. What are the different use cases in real world? Thanks
Flyweight is used when there is clear segregation of the object's intrinsic and extrinsic state exists. Intrinsic state can be shared across other extrinsic objects. For example a header of the documents can be classified as intrinsic state of the object and can be shared across. But rest of the data in the document may be very dynamic and filled by user(extrinsic data). To represent intrinsic data a flyweight object can be created and maintained inside flyweight factory. Flyweight factory object will serve as collection of flyweight(header objects) and can be populated earlier and shared across various instances of the document in our case.