Flyweight is strong when many logical objects share the same immutable core.
Strong Java Use Cases
- text rendering glyph styles
- map tile or sprite metadata
- repeated schema or query-plan metadata
- catalog item templates used by many order lines
- immutable pricing or formatting descriptors reused broadly
Weak Use Cases
Flyweight is weak when:
- object counts are modest
- most state is request-specific
- the factory and cache logic cost more than the duplication
Review Questions
- How many duplicate objects actually exist?
- What portion of their state can be shared safely?
- Is memory pressure large enough to justify the pattern?
Flyweight is a niche but powerful pattern when the numbers support it.