Software Design

Flyweight Pattern: Rendering Massive Forest Canopies

UML Class Diagrams · made in Skemio

UML class diagram showing a Tree holding coordinates and referencing a shared TreeType flyweight containing mesh and texture data, dispensed by TreeFactory.
UML class diagram showing a Tree holding coordinates and referencing a shared TreeType flyweight containing mesh and texture data, dispensed by TreeFactory.

What it shows

  • Splits object state into intrinsic (shared meshes) and extrinsic (coordinates).
  • Reduces memory consumption from hundreds of megabytes to mere kilobytes.
  • Centralizes shared graphical assets in a factory registry.

The takeaway

Separate shared intrinsic state from unique extrinsic state to scale to 100k+ objects.

More uml class diagrams