Flyweight

In boxing, there is a lightweight division between 49 to 52 kgs known as the flyweight division. It was one of the last divisions to be established and was named, I imagine, for the fact that the fighters in it were tiny like flies.

The flyweight pattern is used in instances when there is a large number of instances of objects which only vary slightly. I should perhaps pause here to mention that a large number, in this situation, is probably around 10,000 objects rather than 50 objects. However, the cutoff for the number of instances is highly dependent on how expensive the object is to create. In some cases, the object may be so expensive that only a handful of objects are required before they overload the system. In this case, introducing ...

Get Mastering JavaScript Design Patterns 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.