April 2017
Beginner to intermediate
394 pages
9h 16m
English
The Gang of Four states that a Flyweight is a shared object that can be used in multiple contexts simultaneously. Similarly to flyweight in boxing, which is the lightweight boxing category, we can have a lighter object that can be used in different places in our system simultaneously.
While not used terribly often nowadays, the Flyweight pattern can be very helpful in scenarios when memory is constrained.
A Flyweight will consist of two parts: the intrinsic state and the extrinsic state. The intrinsic state is the part that can be shared. The extrinsic state is modified based on the context it's being used in and, as such, cannot be shared.
Let's take a look at a UML diagram to see a closer look:
We ...
Read now
Unlock full access