The Role of Working Memory in Program Tracing
Will Crichton, Maneesh Agrawala, Pat Hanrahan

TL;DR
This study investigates how working memory impacts program tracing, revealing that memory limitations influence error rates and suggesting interface improvements to aid programmers in managing program state.
Contribution
It demonstrates the transfer of cognitive psychology findings to programming, analyzes tracing strategies, and offers design recommendations to reduce WM load during program comprehension.
Findings
People can hold about 7 variable/value pairs in WM.
On-demand tracing increases WM errors in straight-line code.
Visualizing variable metadata can reduce WM load.
Abstract
Program tracing, or mentally simulating a program on concrete inputs, is an important part of general program comprehension. Programs involve many kinds of virtual state that must be held in memory, such as variable/value pairs and a call stack. In this work, we examine the influence of short-term working memory (WM) on a person's ability to remember program state during tracing. We first confirm that previous findings in cognitive psychology transfer to the programming domain: people can keep about 7 variable/value pairs in WM, and people will accidentally swap associations between variables due to WM load. We use a restricted focus viewing interface to further analyze the strategies people use to trace through programs, and the relationship of tracing strategy to WM. Given a straight-line program, we find half of our participants traced a program from the top-down line-by-line…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
