The flyweight design pattern
Usually when software is written, developers try to make it fast and efficient. Normally, this means less processing cycles and a smaller memory footprint. There are different ways to achieve these two aspects. Most of the time, a good algorithm will take care of the first one. The amount of used memory can have many causes and solutions, and the flyweight design pattern is there to help and reduce the memory used.
Note
The purpose of this design pattern is to minimize the memory usage with the help of an object that shares as much data as possible with other similar objects.
There are many cases where many objects share the same information. A common example when talking about flyweight is word processing. Instead of ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access