Flyweight

In boxing there is a light weight division between 49-52 kg 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 are a large number of instances of objects which vary only slightly. I should perhaps pause here to mention that a large number, in this situation, is probably in the order of 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 are required before they overload the system. In this case introducing ...

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