arrow
Return

An eye tracking study assessing source code readability rules for program comprehension

delete2024-10-05
delete0
PRE
AI
K
Kang-il Park
J
Jack Johnson
C
Cole S. Peterson
N
Nishitha Yedla
I
Isaac Baysinger
J
Jairo Aponte
B
Bonita Sharif *
DOI:10.1007/s10664-024-10532-xdelete
deleteOriginal
deleteShare
deleteSave
Abstract

Abstract

En 中文
ContextWhile developing software, developers must first read and understand source code in order to work on change requests such as bug fixes or feature additions. The easier it is for them to understand what the code does, the faster they can get to working on change tasks. Source code is meant to be consumed by humans, and hence, the human factor of how readable the code is plays an important role. During the past decade, software engineering researchers have used eye trackers to see how developers comprehend code. The eye tracker enables us to see exactly what parts of the code the developer is reading (and for how long) in an objective manner without prompting them.ObjectiveIn this paper, we leverage eye tracking technology to replicate a prior online questionnaire-based controlled experiment (Johnson et al. 2019) to determine the visual effort needed to read code presented in different readability rule styles. As in the prior study, we assess two readability rules - minimize nesting and avoid do-while loops. Each rule is evaluated on code snippets that are correct and incorrect with respect to a requirement.MethodThis study was conducted in a lab setting with the Tobii X-60 eye tracker where each of the 46 participants. 21 undergraduate students, 24 graduate students, and 6 professional developers (part-time or full-time)) participated and were given eight Java methods from a total set of 32 Java methods in four categories: ones that follow/do not follow the readability rule and that are correct/incorrect. After reading each code snippet, they were asked to answer a multiple-choice comprehension question about the code and some questions related to logical correctness and confidence. In addition to comparing the time and accuracy of answering the questions with the prior study, we also report on the visual effort of completing the tasks via gaze-based metrics.ResultsThe results of this study concur with the online study, in that following the minimize nesting rule showed higher confidence (14.8%) decreased time spent reading programming tasks (7.1%), and decreased accuracy in finding bugs (5.4%). However, the decrease in accuracy was not significant. For method analysis tasks showing one Java method at a time, participants spent proportionally less time fixating on code lines (9.9%) and had fewer fixations on code lines (3. 5%) when a snippet is not following the minimize-nesting rule. However, the opposite is true when the snippet is logically incorrect (3.4% and 3.9%, respectively), regardless of whether the rule was followed. The avoid do-while rule, however, did not have as significant of an effect. Following the avoid do-while rule did result in higher accuracy in task performance albeit with lower fixation counts. We also note a lower rate for a majority of the gaze-based linearity metrics on the rule-breaking code snippet when the rule-following and rule-breaking code snippets are displayed side-by-side.ConclusionsThe results of this study show strong support for the use of the minimize nesting rule. All participants considered the minimize nesting rule to be important and considered the avoid do-while rule to be less important. This was despite the results showing that the participants were more accurate when the avoid do-while rule was followed. Overall, participants ranked the snippets following the readability rules to be higher than the snippets that do not follow the rules. We discuss the implications of these results for advancing the state of the art for reducing visual effort and cognitive load in code readability research.
Keywords:
Eye tracking
Source code readability rules
Program comprehension
Correctness
Controlled experiment
The Effect of Comments on Program Comprehension: An Eye-tracking Study
err2026-03-14
err0
errOAAI
errYoussef Abdelsalam; Norman Peitek; Annabelle Bergum; Sven Apel
errShare
errSave
An Eye-Tracking Study of Java Programmers and Application to Source Code Summarization
err2015-11-01
err47
PREAI
errRodeghero, Paige; Liu, Cheng; McBurney, Paul W.; McMillan, Collin
errShare
errSave
Investigating the Feasibility of Conducting Webcam-Based Eye-Tracking Studies in Code Comprehension
err2026-01-06
err0
errOAAI
errZihan Fang; Robert Wallace; Zachary Karas; Toby Li; Collin McMillan; Yu Huang
errShare
errSave
errShare
errSave
errShare
errSave
How do annotations affect Java code readability?
err2024-05-03
err0
PREAI
errGuerra, Eduardo; Gomes, Everaldo; Ferreira, Jeferson; Wiese, Igor; Lima, Phyllipe; Gerosa, Marco; Meirelles, Paulo
errShare
errSave

Journal

Empirical Software Engineering cover
Empirical Software Engineering
IF:
3.6
Papers:
2.0K
Citations:
6.4K

Organization

University of Nebraska System cover
University of Nebraska System
Scholars:
2.7W
Papers: 2.3W
Citations: 2.8W
U
University of Minnesota Twin Cities
Scholars:
260
Papers: 154
Citations: 2.5W
U
university of nebraska lincoln
Scholars:
63
Papers: 38
Citations: 5.7K
researcher View more organizations
Cited Papers

Cited Papers

errShare
errSave
The impact of identifier style on effort and comprehension
err2012-05-03
err113
PREAI
errBinkley, Dave; Davis, Marcia; Lawrie, Dawn; Maletic, Jonathan I.; Morrell, Christopher; Sharif, Bonita
errShare
errSave
Search for seismic discontinuities in the lower mantle
err2001-09-01
err0
errOAAI
errLev Vinnik; Mamoru Kato; Hitoshi Kawakatsu
errShare
errSave
Measuring Program Comprehension: A Large-Scale Field Study with Professionals
err2018-10-01
err195
errOAAI
errXia, Xin; Bao, Lingfeng; Lo, David; Xing, Zhenchang; Hassan, Ahmed E.; Li, Shanping
errShare
errSave
The Hybrid Coronary Approach for Optimal Revascularization
err2020-07-01
err0
errOAAI
errPedro R. Moreno; Gregg W. Stone; Carlos A. Gonzalez-Lengua; John D. Puskas
errShare
errSave
MODALITIES OF SEIZURE ONSET IN TEMPORAL LOBE EPILEPSY
err1996-09-01
err0
PREAI
errF. Arruda; L. F. Quesney; R. Wennberg; A. Olivier
errShare
errSave
researcher View more