Use sharing to support large numbers of fine-grained objects efficiently.
How can large numbers of fine-grained objects be supported efficiently?
Define separate Flyweight objects that store intrinsic (invariant) state.
Clients share Flyweight objects and pass in extrinsic (variant) state instead of creating an object each time it is needed.
✅ Enables abstractions at the finest levels. ✅ Reduces memory usage.
❌ Increases runtime-cost. ❌ Increases code complexity.
Last updated 1 year ago