It's impossible to eliminate all coding errors, but it is certainly worth taking measures to reduce their frequency. A novel approach looks at using psycho-physiological measures.
Programmers often work long hours, typing code while staring at computer monitors, and are often under time pressure to deliver the programs they are working on. It's hardly surprising that bugs creep in, but, as programming mistakes can cause serious problems for users, it is also important to address the problem.
Microsoft Researcher Andrew Begel, together with academic and industry colleagues have been trying to detect when developers are struggling as they work, in order to prevent bugs before they are introduced into code. Explaining the rationale Begel says:
“My idea is that if the software developers are writing the code and causing the bugs, we should measure attributes of the developers themselves. If we can figure out what cognitive or emotional issues lead to buggy code or lowered productivity, we can try to intervene and stop them from causing developers to make mistakes in the first place.”
A paper presented at the 36th International Conference on Software Engineering and discussed at this month's Microsoft Research Faculty Summit, reports on a study conducted with 15 professional programmers to see how well an eye-tracker, an electrodermal activity (EDA) sensor, and an electroencephalography (EEG) sensor could be used to predict whether developers would find a task to be difficult. The aim was to investigate an automated approach and the experimental result showed that it was possible to train a Naive Bayes classifier to predict whether a new participant will perceive tasks to be difficult with a precision of nearly 65 percent. For new tasks, the number was even higher: almost 85 percent.
Does this suggest that in future developers will be expected to work routinely hooked up to an array of psycho-physiological measuring devices?
The good news from the study seems to be that eye tracking alone produces fairly good results.
Going beyond this initial investigation researchers now need to decide how to support developers who are finding their work difficult. On the Inside Microsoft Research blog, Rob Knies writes:
What isn’t known yet is how developers will react if their actions are approaching bug-potential levels and an intervention is deemed necessary.
He quotes Andrew Begel as saying:
“We haven’t tried any interventions yet, but one I’ve thought about can help absent-minded developers, such as those who just came back from lunch and aren’t paying much attention to their code. If we reduce the contrast on the display and make the fonts harder to read, the developer will be forced to apply more brainpower to read and understand the code and will be less likely to slip up as a result.”