© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2022
V. SarcarJava Design Patternshttps://doi.org/10.1007/978-1-4842-7971-7_12

12. Flyweight Pattern

Vaskaran Sarcar1  
(1)
Garia, Kolkata, India
 

This chapter covers the Flyweight pattern.

GoF Definition

It uses sharing to support large numbers of fine-grained objects efficiently.

Concept

This pattern may look simple but if you do not identify the core concepts, the implementations may appear to be complex. So, I’ll start with a very basic and detailed explanation before you implement this pattern. Let’s start.

Sometimes you need to handle lots of objects that are very similar (but not the same). But the constraint is that you cannot create all of them to lessen resource ...

Get Java Design Patterns: A Hands-On Experience with Real-World Examples now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.