December 2017
Intermediate to advanced
468 pages
13h 12m
English
Flyweight suggests using the shared support of a vast number of fine-grained objects. We can use the Flyweight pattern to reduce the number of objects created (by sharing) and thereby reduce the memory footprint and improve the performance.

The preceding diagram depicts the general structure of the Flyweight pattern and a sample implementation. Consider a massive object that is shared across printer and a screen; Flyweight is a good option and can be cached as well (say for printing multiple copies).
Here are the benefits: