Chapter    17

The Flyweight Pattern

The flyweight pattern is applied when a number of similar objects all rely on the same set of data values. Rather than create a new set of data valued for each of the objects, the flyweight pattern shares one set between all of them, minimizing the amount of memory required to store the data and the amount of work required to create them. Table 17-1 puts the flyweight pattern into context.

Table 17-1. Putting the Flyweight Pattern into Context

Question

Answer

What is it?

The flyweight pattern shares common data objects between multiple calling components.

What are the benefits?

The flyweight pattern reduces the amount of memory needed to create the data objects required by the calling components and the amount ...

Get Pro Design Patterns in Swift now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.