Does Code Structure Affect Comprehension? On Using and Naming Intermediate Variables
Roee Cates, Nadav Yunik, Dror G. Feitelson

TL;DR
This study investigates how the use and naming of intermediate variables in code affect comprehension, finding that meaningful names generally aid understanding, especially in complex cases, while poor naming can hinder it.
Contribution
It provides empirical evidence on the impact of intermediate variable naming on code comprehension, highlighting the importance of meaningful names.
Findings
Meaningful names improve understanding in complex functions
Poorly named variables can slightly decrease comprehension
In most cases, code structure has minimal impact on understanding
Abstract
Intermediate variables can be used to break complex expressions into more manageable smaller expressions, which may be easier to understand. But it is unclear when and whether this actually helps. We conducted an experiment in which subjects read 6 mathematical functions and were supposed to give them meaningful names. 113 subjects participated, of which 58% had 3 or more years of programming work experience. Each function had 3 versions: using a compound expression, using intermediate variables with meaningless names, or using intermediate variables with meaningful names. The results were that in only one case there was a significant difference between the two extreme versions, in favor of the one with intermediate variables with meaningful names. This case was the function that was the hardest to understand to begin with. In two additional cases using intermediate variables with…
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.
