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

Ahmad Jbara, Dror G. Feitelson

Research output: Contribution to journalArticle

17 Scopus citations

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.

Original languageEnglish (US)
Pages (from-to)1440-1477
Number of pages38
JournalEmpirical Software Engineering
Volume22
Issue number3
DOIs
StatePublished - Jun 1 2017
Externally publishedYes

Keywords

  • Code regularity
  • Controlled experiment
  • Eye-tracking
  • Software complexity

ASJC Scopus subject areas

  • Software

Fingerprint Dive into the research topics of 'How programmers read regular code: a controlled experiment using eye tracking'. Together they form a unique fingerprint.

  • Cite this