Flyweight
Advanced · 12 min read · Low-Level Design, Structural Patterns
Sharing intrinsic state to support huge numbers of small objects.
This is an Advanced lesson, part of Premium. What it covers:
- The idea in plain words
- The problem
- The solution: split intrinsic and extrinsic state
- Rules for a correct flyweight
- Where you've seen it
- Trade-offs
- Related patterns
- How much does it actually save?
- A runnable example: styled text
- Common mistakes
- Interview questions
- Further reading