arrow
Return

Refactoring for Novices in Java: An Eye Tracking Study on the Extract vs. Inline Methods

delete2026-02-28
delete0
PRE
AI
J
José Aldo Silva da Costa
R
Rohit Gheyi
J
José Júnior Silva Da Costa
M
Márcio Ribeiro
R
Rodrigo Bonifácio
H
Hyggo Almeida
A
Ana Carla Bibiano
A
Alessandro Garcia
DOI:10.1016/j.jss.2026.112825delete
deleteOriginal
deleteOriginal request for help
deleteShare
deleteSave
Abstract

Abstract

En 中文
Developers extract methods aiming to make the code easier to read, understand, and reuse. Inlining keeps logic in a single block, while method extraction isolates functionality into a named unit, which is a common practice. Although prior studies using static metrics have not found clear differences between these practices, the human factor in code comprehension and navigation remains underexplored. Code metrics might not capture other dynamic aspects such as the impact of method extraction on the visual effort of developers. Therefore, we aim to investigate the impact of Inline Method and Extract Method refactorings on code comprehension using a dynamic approach based on tracking participants’ eye movements as they interact with the code. Through eye tracking, we examine how small structural changes such as introducing or removing short methods affect code comprehensibility by analyzing key code areas and comparing visual effort, reading behavior, fixation durations, and revisit patterns. We conduct a controlled experiment with 32 novices in Java, followed by short post-task interviews to capture their difficulties, strategies, and impressions. Each participant solved eight simple tasks comprising four programs with the method inlined and four with the method extracted. We compare them by measuring time, number of attempts, and visual effort with fixation duration, fixations count, and regressions count. Complementarily, we survey 58 additional novices to obtain both quantitative and qualitative data. We found that while traditional metrics such as time revealed significant percentage changes, eye tracking metrics varied even more; in two programming tasks, method extraction improved comprehension and reduced visual effort, with time decreasing by up to 78.8% and regressions by 84.6%. However, for simpler tasks, such as calculating the area of a square, the opposite occurred: time increased by up to 166.9% and regressions by 200%. This suggests that even well-named methods can disrupt novices’ linear reasoning and require costly visual navigation. We found evidence that meaningful method names (beacons) do not always improve code comprehension for Java novices in the context of refactoring. Despite the presence of meaningful names, participants still navigated back and forth between the method call and its extracted method, resulting in increased visual effort and cognitive processing time. To complement our analysis, we surveyed 58 additional novices about their preferences and impressions. While many preferred extracted versions for their readability and reuse, some of their preferences did not always align with their performance, highlighting a gap between perceived and actual comprehension. The integration of these metrics with participant feedback and their preferences suggests that the modularization introduced by an extracted method may slow down problem-solving for novices due to the increased navigation effort it requires. We observed an increased number of gaze transitions, which can disrupt novices’ mental flow. Our findings complement previous studies and have important implications for educators suggesting caution when applying premature modularization to novices in Java. They also highlight the need to better understand when and for whom each refactoring should be applied. For researchers, our study underscores the value of eye tracking in revealing effects that static metrics may not capture.
Keywords:
Method Extraction
Inline Method
Code Comprehension
Eye Tracking
Refactoring

Journal

Journal of Systems and Software cover
Journal of Systems and Software
IF:
4.1
Papers:
5.4K
Citations:
8.4K

Organization

U
university of paraiba
Scholars:
2
Papers: 2
Citations: 0
F
federal university of alagoas
Scholars:
300
Papers: 104
Citations: 0
F
federal university of campina grande
Scholars:
212
Papers: 63
Citations: 0
U
University of Brasilia
Scholars:
405
Papers: 167
Citations: 0
P
pontifical catholic university of rio de janeiro
Scholars:
169
Papers: 76
Citations: 0
researcher View more organizations