
The Rule of Seven and Cognitive Load

#89 - Code That Fits in Your Head - Mark Seemann
Topic 5 of 11
Published May 23, 2022 · Clip 23:14–28:35 (5:21)
Mark explains the Rule of Seven, based on George Miller's 1956 paper 'The Magical Number Seven Plus Minus Two': short-term memory can hold about seven items. Reading code is like running an interpreter in the brain that must track state, so code should not require tracking more than about seven things. Seven is chosen for memorability. He advocates team-agreed thresholds like cyclomatic complexity (typically three or four in his code, never more than seven) and other simple metrics countable by a human during code review or pair programming.