Flyweight
Explore how the Flyweight design pattern helps reduce memory usage by sharing intrinsic state among many fine-grained objects. Understand the difference between intrinsic and extrinsic states and see how this pattern optimizes applications that handle large numbers of similar objects, such as an aircraft radar system, enabling you to create memory-efficient and flexible software solutions.
We'll cover the following...
What is it ?
Flyweight is a category in boxing competitions for light weight boxers. The intent of the pattern is somewhat similar in that it tries to reduce bloated code to a more compact and lean representation, which uses less memory.
Formally, the pattern is defined as sharing state among a large number of fine-grained objects for efficiency.
Class Diagram
The class diagram consists of the following entities
- Flyweight
- Concrete Flyweight
- Unshared Concrete Flyweight
- Flyweight Factory