Wallace, Robert; Bansal, Aakash; Karas, Zachary; Tang, Ningzhi; Huang, Yu; Li, Toby Jia-Jun; McMillan, Collin. “Programmer Visual Attention During Context-Aware Code Summarization.” IEEE Transactions on Software Engineering (2025). https://doi.org/10.1109/TSE.2025.3554990.
When programmers write or understand code, they naturally focus their eyes on certain parts of the screen—that’s what we call programmer attention. Past research has tried to track this attention using tools like eye trackers, mouse movements, or keyboard activity. But most of these studies only looked at small pieces of code, like one function or method at a time.
This creates a problem because many programming tasks, like writing a short summary of what a piece of code does, require understanding the bigger picture. In other words, programmers often need to look at other parts of the project to gather enough context—not just the code right in front of them.
To explore this, we ran a study with 10 experienced Java programmers. Each of them summarized 40 different pieces of code taken from five large Java projects, working over five one-hour sessions. While they worked, we used eye-tracking technology to see exactly where they were looking and how long they focused on each part of the code. We also rated the quality of the summaries they wrote.
What we discovered was interesting: over time, programmers needed to read about 35% fewer words and re-read 13% less code during each session—without their summaries getting any worse. We also found that reading more code generally helped them write better summaries—but only up to a point. After that point, reading too much actually made the summaries worse.
We also looked at where programmers were looking for context. It turns out they mostly focused on methods in the same class as the one they were summarizing. Surprisingly, they didn’t spend much time looking at related methods that the code directly called, even though those might seem important.
In summary, our findings give new insight into how programmers focus their attention across a project while working on code-related tasks. This could help future tools do a better job of automatically summarizing code or supporting programmers in understanding complex projects.
