© Vaskaran Sarcar 2018
V. SarcarDesign Patterns in C#https://doi.org/10.1007/978-1-4842-3640-6_10

10. Flyweight Pattern

Vaskaran Sarcar1  
(1)
Whitefield, Bangalore, Karnataka, India
 

This chapter covers the Flyweight pattern.

GoF Definition

Use sharing to support large numbers of fine-grained objects efficiently.

Concept

The GoF said the following about flyweights:

A flyweight is a shared object that can be used in multiple contexts simultaneously. The flyweight acts as an independent object in each context—it’s indistinguishable from an instance of the object that’s not shared. Flyweights cannot make assumptions about the context in which they operate. The key concept here is the distinction between intrinsic and extrinsic state. Intrinsic state is stored ...

Get Design Patterns in C#: A Hands-on Guide with Real-World Examples 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.