Definition
Use sharing to support large numbers of fine-grained objects efficiently.
UML Class Diagram
Flyweight: when and where use it
The intent of the Flyweight design pattern is to share large numbers of fine-grained objects efficiently. Shared flyweight objects are immutable, that is, they cannot be changed as they represent the characteristics that are shared with other objects. Examples include, characters and line-styles in a word processor or digit receivers in a public switched telephone network application. You will find flyweights mostly in utility type applications (word processors, graphics programs, network apps). They are rarely used in data-driven business type applications.
Sample
- Fly-weight class
- Concrete fly-weight class
- Factory class
- Client
Ref: Gang of Four tutorial
No comments:
Post a Comment