Chapter 13. Flyweight

The FLYWEIGHT pattern provides for sharing an object between clients, creating a responsibility for the shared object that normal objects need not consider. An ordinary object doesn't have to worry much about shared responsibility. Most often, only one client will hold a reference to an object at any one time. When the object's state changes, it's because the client changed it, and the object does not have any responsibility to inform any other clients. Sometimes, though, you will want to arrange for multiple clients to share access to an object.

One incentive for sharing an object among multiple clients occurs when you must manage thousands or tens of thousands of small objects, such as the characters in an online version ...

Get Design Patterns in C# now with O’Reilly online learning.

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