Skip to search boxSkip to navigationSkip to main content

How programmers read regular code: a controlled experiment using eye tracking

  • Ahmad Jbara(corresponding author)
    ,
  • Dror G. Feitelson
*Corresponding author for this work
  • Netanya Academic College
    ,
  • Hebrew University of Jerusalem
Scholary Output:
Contribution to journal
Article
Peer-review

Abstract

Regular code, which includes repetitions of the same basic pattern, has been shown to have an effect on code comprehension: a regular function can be just as easy to comprehend as a non-regular one with the same functionality, despite being significantly longer and including more control constructs. It has been speculated that this effect is due to leveraging the understanding of the first instances to ease the understanding of repeated instances of the pattern. To verify and quantify this effect, we use eye tracking to measure the time and effort spent reading and understanding regular code. The experimental subjects were 18 students and 2 faculty members. The results are that time and effort invested in the initial code segments are indeed much larger than those spent on the later ones, and the decay in effort can be modeled by an exponential model. This shows that syntactic code complexity metrics (such as LOC and MCC) need to be made context-sensitive, e.g. by giving reduced weight to repeated segments according to their place in the sequence. However, it is not the case that repeated code segments are actually read more and more quickly. Rather, initial code segments receive more focus and are looked at more times, while later ones may be only skimmed. Further, a few recurring reading patterns have been identified, which together indicate that in general code reading is far from being purely linear, and exhibits significant variability across experimental subjects.

Publication Information

Output type

Scholary Output:
Contribution to journal
Article
Peer-review

Original language

English (US)

Pages from-to (Number of pages)

Pages 1440-1477 (38 pages)

Journal (Volume, Issue Number)

Empirical Software Engineering (Volume 22, Issue 3)

Publication milestones

  • Published - 06/01/2017

Publication status

Published - 06/01/2017

ISSN

1382-3256

Publication IDs

  • Scopus: 84996538088

Publication metrics

Metrics

SciVal
citations
26
Scopus
citations
SciVal
FWCI
1.91
SciVal
Author count
2
SciVal
Paper percentile
92
SciVal
Top percentile
10
Fractional count
1
Fractional count
0.50
Fractional count
1
Fractional count
0.50
Fractional count
1
Fractional count
1

PlumX, opens in new tab

Captures
102
Citation count
54

Funding Details

This research was supported by the ISRAEL SCIENCE FOUNDATION (grant no. 407/13). Many thanks to the reviewers of this extended version who helped to improve the paper considerably in terms of analysis and presentation relative to the original conference version.
FunderFunding number
ISF
407/13