Hermes Wiki

Flyweight

Shares common, immutable state across many objects instead of duplicating it, to cut memory use when a large number of similar objects exist.

Why we need this / what value this brings

Cuts memory use by sharing the state that's identical across many instances, instead of each instance holding its own copy.

How to use or implement this

Split an object's state into 'intrinsic' (shared, immutable — safe to share via a cache/pool) and 'extrinsic' (unique per instance, passed in by the caller).

When to use this

You need a very large number of similar objects and per-instance state is small relative to the shared state.

Research questions

  • Rarely justified in a typical CRUD backend at Localz's current scale — worth revisiting only if a specific hot path shows real memory pressure from many near-identical objects (e.g. rendering a large service-category list).

Empty folder — drop notes, links, and findings here as you research.

Hermes Wiki