Java Reference
In-Depth Information
Step 6 Make sure you understand each bug before you fix it.
Once you find that a loop makes too many iterations, it is very tempting to apply a
ȒBand-Aidȓ solution and subtract 1 from a variable so that the particular problem
doesn't appear again. Such a quick fix has an overwhelming probability of creating
trouble elsewhere. You really need to have a thorough understanding of how the
program should be written before you apply a fix.
It does occasionally happen that you find bug after bug and apply fix after fix, and
the problem just moves around. That usually is a symptom of a larger problem
with the program logic. There is little you can do with the debugger. You must
rethink the program design and reorganize it.
R ANDOM F ACT 6.3: The First Bug
According to legend, the first bug was one found in 1947 in the Mark II, a huge
electro-mechanical computer at Harvard University. It really was caused by a
bugȌa moth was trapped in a relay switch. Actually, from the note that the
operator left in the log book next to the moth (see The First Bug figure), it appears
as if the term Ȓbugȓ had already been in active use at the time.
The pioneering computer scientist Maurice Wilkes wrote: ȒSomehow, at the
Moore School and after wards, one had always assumed there would be no
particular difficulty in getting programs right. I can remember the exact instant in
time at which it dawned on me that a great part of my future life would be spent
finding mistakes in my own programs.ȓ
274
275
The First Bug
Search WWH ::




Custom Search