Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

README.md

Outline
layout title folder permalink pumlid categories tags
pattern
Flyweight
flyweight
/patterns/flyweight/
HSV94S8m3030Lg20M7-w4OvYAoCh7Xtnq3ty-Eq-MQlaJcdow17JNm26gpIEdkzqidffa4Qfrm2MN1XeSEADsqxEJRU94MJgCD1_W4C-YxZr08hwNqaRPUQGBm00
Structural
Java
Gang Of Four
Difficulty-Intermediate
Performance

Intent

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

alt text

Applicability

The Flyweight pattern's effectiveness depends heavily on how and where it's used. Apply the Flyweight pattern when all of the following are true

  • an application uses a large number of objects
  • storage costs are high because of the sheer quantity of objects
  • most object state can be made extrinsic
  • many groups of objects may be replaced by relatively few shared objects once extrinsic state is removed
  • the application doesn't depend on object identity. Since flyweight objects may be shared, identity tests will return true for conceptually distinct objects.

Real world examples

Credits

Morty Proxy This is a proxified and sanitized view of the page, visit original site.