In many companies, programmers are prohibited from working with headphones or distracting them from minor issues. Probably the reason lies in the poor awareness of managers and other employees, how harmful it is to do so.
Chris Parnin from the Georgia Institute of Technology decided to fill this gap and published an
extremely rich article with links to various studies on this topic.
For a start, a few facts that apply to all intellectual workers. A task interrupted in the course of execution takes twice as long and contains twice as many errors as the same task that was performed without interruption (
Czerwinski: 04 ). Office employees are forced to be distracted while performing 57% of tasks (
Mark: 05 ). Surveys suggest that it takes an average of 15 minutes for an employee to return to a normal rhythm after being distracted (
vanSolingen: 98 ).
Chris Parnin conducted his own extensive
research among programmers (pdf). About 10,000 work sessions in Eclipse and Visual Studio from 414 developers were analyzed. Here is what was found:
')
• It takes the programmer 10 to 15 minutes to start writing code after resuming work.
• The programmer usually manages only one 2-hour work session without distractions during the work day.
• In most cases, after resuming work, the programmer scrolls the project to certain areas to restore the context.
• Programmers insert special compilation errors as “reminders.”
• Source code diff serves as the last chance to recover events, but can be cumbersome for this task.
Chris Parnin and his colleagues studied the work segments in which the programmer was the worst to distract. Studies with measurements of the diameter of the pupils have shown that the greatest harm is caused by interruption of work during the period of maximum memory load.

In this case, the programmer needs at least 7 minutes to move from the state of maximum memory activity to the state of minimum activity. Extrapolating these results to the working sessions of programmers, Parnin found that the worst thing to distract the programmer during the execution of the following tasks:
- During code changes, especially during simultaneous code changes in several places.
- Navigation and search activity.
- Understanding the data flow and the order of execution of instructions in the code.
- The IDE window is out of focus.

Chris Parnin in his
blog describes some of the features of the human memory and publishes the
preliminary results of functional magnetic resonance imaging programmers during work.