practice
SOFTWARE DEVELOPERS SPEND 35%–50% of their
time validating and debugging software.
1 The cost of
debugging, testing, and verification is estimated to
account for 50%–75% of the total budget of software
development projects, amounting to more than
$100 billion annually.
11 While tools, languages,
and environments have reduced the time spent on
individual debugging tasks, they have not significantly
reduced the total time spent debugging, nor the cost
of doing so. Therefore, a hyperfocus on elimination
of bugs during development is counterproductive;
programmers should instead embrace debugging as
an exercise in problem solving.
It is more appropriate for programmers to focus their
efforts on acquiring and encouraging effective learning
strategies that reduce the time spent
debugging, as well as changing the way
they perceive the challenge. This ar-
ticle describes how effective problem-
solving skills can be learned, taught,
and mentored through applying re-
search on the psychology of problem
solving, conducted by Stanford’s Carol
Dweck and others.
In the 1974 classic, The Elements
of Programming Style, Kernighan and
Plauger wrote, “Everyone knows that
debugging is twice as hard as writing a
program in the first place. So if you are
as clever as you can be when you write
it, how will you ever debug it?”
6 Is de-
bugging really twice as hard as writing
a program? If so, why should it be?
To answer these questions, let’s first
consider why bugs occur. In a 2005
paper, Andrew J. Ko and Brad A. Mey-
ers suggest that bugs occur as a result
of “chains of cognitive breakdowns...
formed over the course of program-
ming activity.”
7
At a fundamental level, all software
describes changes in the state of a sys-
tem over time. Because the number
states and state transitions in soft-
ware can have combinatorial complex-
ity, programmers necessarily rely on
approximations of system behavior
(called mental models) during develop-
ment. The intent of a mental model is
to allow programmers to reason accu-
rately about the behavior of a system.
Since mental models are approximations, they are sometimes incorrect,
leading to aberrant behavior in software
when it is developed on top of faulty assumptions. Neophyte programmers
experience this problem to a greater
degree: their models of the language
and development environment are necessarily incomplete, and even a simple
syntax error can be a major blocker for
someone learning to program. This is
not limited to novice programmers.
The C11 language specification is just
north of 700 pages, for example. How
many systems programmers understand the language completely?
The most sinister bugs occur when
programmers falsely believe their men-
The
Debugging
Mind-Set
DOI: 10.1145/3052939
Article development led by
queue.acm.org
Understanding the psychology
of learning strategies leads to
effective problem-solving skills.
BY DEVON H. O’DELL