Magic Number
Updated 2026-07-30
Summary
A specific numeric literal used directly in code without explaining its meaning, such as if x > 30.
Definition
Refers to specific numbers used directly in code without explanation of their meaning (e.g., if x > 30). Good practice is to define numbers as meaningful constants (e.g., MAX_USER_LIMIT = 30). Scaffold use: enhance explicitness. In work and life, do not throw out conclusions without context (magic numbers), but explain the underlying logic and definitions (constant names). This greatly reduces the cost of understanding and maintenance for others.
Introduction
How to use
Enhance explicitness. In work and life, do not throw out conclusions without context (magic numbers), but explain the underlying logic and definitions (constant names). This greatly reduces the cost of understanding and maintenance for others.
Mechanism
The 'magic number' most commonly refers to Miller's (1956) finding that human working memory can hold about 7±2 chunks at once. Another meaning is the particularly stable proton/neutron numbers in nuclear physics (2, 8, 20...). Both refer to 'a number that happens to be critical'.
Practice
In progress 0/3Practice this model in one real situation:
Cases
- Phone numbers segmented, menus around seven items are easier to remember; closed shells in nuclear structure.
Common pitfalls
- Treating 7±2 as a precise upper limit—actually greatly affected by chunking and familiarity; capacity varies across tasks.
Sources
Source support: Explicit
References currently contain only Wikipedia links; primary sources still need review.
- en.wikipedia.orghttps://en.wikipedia.org/wiki/Magic_numberverified
account_treeGenealogyexpand_more
PRIVATE NOTES · Only visible to you
SAVED Q&A
ENTRY Q&A · Private saving available
Ask with a clear boundary
thinkingmodels answers from published entry context only.
Your question is sent to thinkingmodels. The answer uses public entry context only.
RELATED MODELS