The Flyweight design pattern is a structural pattern that focuses on minimizing the memory footprint or computational expenses of an object. It achieves this by sharing as much as possible with related objects, rather than keeping all of the data in each object. This is particularly useful when dealing with a large number of similar objects, as it helps reduce the overall memory consumption and improves performance.
Purpose of Flyweight Pattern:
- To reduce the number of objects and to conserve memory by sharing objects among multiple contexts.
- To achieve performance improvement by minimizing the overhead of creating and managing large numbers of similar objects.