Cognitive Scaffold

Preparing your thinking workspace

arrow_back_ios_new
MENTAL MODEL · M7355

Flyweight Pattern

Flyweight Pattern
BusinessHigh supportManagement
Included
account_tree

Updated 2026-07-30

Loading revision record…

Summary

In computer programming, the flyweight software design pattern refers to an object that minimizes memory usage by sharing some of its data with other similar objects. The flyweight pattern is one of twenty-three GoF design patterns. In other contexts, the idea of sharing data structures is called ha…

Definition

A design pattern that reduces memory usage by sharing as much data as possible. It divides object state into intrinsic state (shareable) and extrinsic state (non-shareable). Scaffold use: Optimize resource allocation. When dealing with a large number of similar tasks or objects, extract the invariant 'common denominator' for reuse, and handle only the differences separately to reduce system load.

How to use

Optimize resource allocation. When dealing with a large number of similar tasks or objects, extract the invariant 'common denominator' for reuse, and handle only the differences separately to reduce system load.

Mechanism

Reduce memory/resource usage by sharing the common parts of a large number of fine-grained objects, replacing repetition with sharing.

Practice

In progress 0/1

Practice this model in one real situation:

Check to track your progress (stored locally)
Learning progress0%

Cases

  • Character style sharing in text editors; many similar objects in games.

Common pitfalls

  • Sharing the wrong objects leads to coupling; ignoring thread safety; over-engineering.
Sources

Source support: Explicit

References currently contain only Wikipedia links; primary sources still need review.

  • link
    en.wikipedia.orghttps://en.wikipedia.org/wiki/Flyweight_patternZH · Explicit
    verified
account_treeGenealogyexpand_more

RELATED MODELS