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.
The purpose of the flyweight 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 representing each character with all the information about font, size, color, image, and so on, we could just store the positions...