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

03/19/2021
by   Roee Cates, et al.
0

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 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 meaningless names appears to have caused a slight decrease in understanding. In all other cases the code structure did not make much of a difference. As it is hard to anticipate what others will find difficult to understand, the conclusion is that using intermediate variables is generally desirable. However, this recommendation hinges on giving them good names.

READ FULL TEXT
research
03/12/2021

How Developers Choose Names

The names of variables and functions serve as implicit documentation and...
research
03/15/2021

Using Non-Verbal Expressions as a Tool in Naming Research

Variable and function names are extremely important for program comprehe...
research
07/12/2019

Mercem: Method Name Recommendation Based on Call Graph Embedding

Comprehensibility of source code is strongly affected by identifier name...
research
09/07/2022

When Are Names Similar Or the Same? Introducing the Code Names Matcher Library

Program code contains functions, variables, and data structures that are...
research
03/25/2021

Towards a Model to Appraise and Suggest Identifier Names

Unknowingly, identifiers in the source code of a software system play a ...
research
08/13/2021

Augmenting Decompiler Output with Learned Variable Names and Types

A common tool used by security professionals for reverse-engineering bin...
research
02/22/2023

Rename Chains: An Exploratory Study on the Occurrence and Characteristics of Identifiers Undergoing Multiple Renamings

Identifier names play a significant role in program comprehension activi...

Please sign up or login with your details

Forgot password? Click here to reset