Does Code Structure Affect Comprehension? On Using and Naming\n Intermediate Variables

Intermediate variables can be used to break complex expressions into more\nmanageable smaller expressions, which may be easier to understand. But it is\nunclear when and whether this actually helps. We conducted an experiment in\nwhich subjects read 6 mathematical functions and were supposed to give them\nmeaningful names. 113 subjects participated, of which 58% had 3 or more years\nof programming work experience. Each function had 3 versions: using a compound\nexpression, using intermediate variables with meaningless names, or using\nintermediate variables with meaningful names. The results were that in only one\ncase there was a significant difference between the two extreme versions, in\nfavor of the one with intermediate variables with meaningful names. This case\nwas the function that was the hardest to understand to begin with. In two\nadditional cases using intermediate variables with meaningless names appears to\nhave caused a slight decrease in understanding. In all other cases the code\nstructure did not make much of a difference. As it is hard to anticipate what\nothers will find difficult to understand, the conclusion is that using\nintermediate variables is generally desirable. However, this recommendation\nhinges on giving them good names.\n

Paper

Similar papers

© 2026 NYSGPT2525 LLC