Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
29547 views
1
2
3
4
5
6
Getting Buggy Wit It
7
8
There I was, late one night
9
in the Microsoft software factory, furiously exterminating some of the skankier
10
bugs from my areas of Outlook 97, our e-mail program. My skill at writing
11
software, I believe, is God-given. My legendary success at squashing bugs, I
12
believe, is the result of my tendency to write buggy code. So it was no
13
surprise when one of the dozens of software testers employed by the Outlook 97
14
team sent me urgent e-mail. He had discovered a giant bug in my area and was
15
insistent I inspect it.
16
17
The first
18
thing you do when a tester brings you a bug is reproduce it. In this case,
19
reproduction would be easy. Step 1: Create an appointment in Outlook's
20
calendar. Step 2: Add a conference room to the appointment. So far so good.
21
Step 3: Change the date of the appointment to the year 4500. Step 4: Switch to
22
the meeting planner page. Step 5 ...
23
24
Istopped reading the tester's e-mail and wrote back.
25
Although it was a bad bug, I felt confident I could ignore it for, oh, 2,000
26
years or so. But Shuman, the crowds chant, doesn't that mean you willingly
27
shipped buggy software? That you deliberately added to the torment of millions
28
of computer users who can't get their software to work? Why shouldn't
29
Outlook 97 be able to handle appointments in specified conference rooms in
30
future millenniums?
31
32
Well,
33
folks, I've got news for you: Nothing is perfect, and software is no exception.
34
Today's robust software products from Microsoft, Lotus, Borland, Corel, and all
35
the rest are too damn complex to be perfect. How complex are they? Microsoft's
36
Windows 95 operating system contains more than 10 million lines of code, or
37
instructions. Compare that with the 6 million parts in a Boeing 747, 3 million
38
of which are fasteners such as rivets. Fasteners are wonderful, but they don't
39
interact much with one another. The difficult thing about writing software is
40
that all 10 million parts of Windows 95 are tightly coupled. Pop a rivet on
41
your 747, and you're still likely to make your destination. But bollix up one
42
line of code in Windows 95, and users' computer screens will turn screaming
43
blue and crash.
44
45
46
What are bugs, anyway? And what makes them more
47
insidious than a few blown rivets? Bugs are errors, somewhat analogous to typos
48
or factual errors in newspaper articles, but the difference is that a typo is
49
almost never enough to spoil an entire edition of a newspaper, whereas a tiny
50
error in a software program can scuttle it. Take the year 2000 bug for example.
51
The Y2K bug arises because past programmers expressed years with two digits
52
rather than four, so that the year 1915 is written as 15. Thus to the computer,
53
the year 2015 looks the same as the year 1915. (Click to find out why
54
programmers deliberately created the Y2K bug, and why that wasn't such a crazy
55
thing to do.) The Y2K bug is a very bad bug; the one tiny decision about how to
56
express dates can bring a whole program to a screeching halt.
57
58
Bugs fall
59
into two major categories: crashing and functional. Crashing bugs are so
60
naughty that they cause programs to stop functioning. Usually, this results in
61
friendly warnings--such as "Illegal Operation" for Windows users or the lovely
62
picture of a bomb for Macintosh users. The other type of bug is a functional
63
bug--e.g., the Y2K bug--which is subtler in nature. Functional bugs cause
64
programs to fail or to give erroneous results. The number of either kind of bug
65
is proportional to the size of the program.
66
67
But, as Shuman can tell you, it's easy to write bugs into
68
simple, short programs, like one designed to find a single word in a sentence.
69
Actually, it's not that simple an operation. You must write perfectly logical
70
statements in a language that the computer can understand. If you were to write
71
this program in C, a popular programming language, it would take three lines of
72
code to tell the program to look at the beginning of the word and the beginning
73
of each sentence. Next, you'd instruct the computer to match each character in
74
the word you are searching for to the corresponding characters in the sentence.
75
If the letters are the same, you continue. This would take five lines of code.
76
Then you would have to confirm you have gone through all the letters in the
77
word successfully. Chalk up two more lines. Then you'd need to see if there are
78
any letters in the sentence left to compare. Two lines of code. Lastly, you
79
would have to inform the user of your program what happened. Another three
80
lines--15 lines of code to find one word! Shuman is exhausted just thinking
81
about it, and he hasn't even started creating bugs! Dropping one essential
82
instruction or writing the lines of code in the wrong order could spell
83
destruction for my little program. (For all the gory details on how I actually
84
wrote this program in C, click .)
85
86
Civilians
87
assume software companies spend most of their time writing software. Wrong!
88
They spend most of their time testing software! After developers write a
89
few lines of code, we test it for bugs and sit down with our testers to imagine
90
all the ways the program will be used. Good testers make gnarly demands on the
91
code, inventing disaster scenarios worthy of Hollywood. (My favorite tester
92
routinely yanked the power cord out of the computer during Outlook operations
93
to see how the program handled loss of power.) Testers run the software on
94
different PCs--how will it work on a Hewlett Packard computer vs. a Packard
95
Bell? They print with old printers. They enter thousands of lines of text into
96
small fields. One tester placed most of the text of the King James Bible into
97
an e-mail message, sent it to himself, and then replied to the e-mail. Outlook
98
choked at this point, demanding a day of rest. God was watching. Here at
99
100
Slate
101
we rarely tug on the power cord to test our code, but we do
102
test the site on a variety of browsers.
103
104
105
At the beginning of a software project, code is
106
buggy, because we're still getting different parts of the program to cooperate.
107
A line of code that tells the program how to print may clash with the code that
108
tells the program how to draw the screen. As testers hunt bugs, developers
109
conspire with the marketing department to add features to the product, which
110
breeds more potential bugs. Adding new features to a stable program can be
111
dangerous. Developers can create bugs faster than testers can capture them, and
112
testers can capture them faster than developers can kill them, so the only way
113
to finish a product is to stop adding features and start paying attention to
114
the bugs.
115
116
117
Preventing developers from adding features is not as easy as it sounds. They
118
love to build things--not to fix things. One way to deter them is to break
119
their arms with a baseball bat. Given infinite time, developers would prefer to
120
add feature upon feature and never release their product. But marketing people
121
are the worst offenders when it comes to wanting to add new features,
122
generating loud choruses of "NO" even from otherwise enthusiastic
123
developers.
124
125
Agood tester is like the Roach Motel, corralling bugs and
126
ensnaring them. "Look what I caught!" the tester meows as he drops the vermin
127
on the developer's doorstep. Testers are as vain about finding bugs as I am
128
about squashing them, hence the excessive pride of my tester who uncovered the
129
year 4500 bug.
130
131
Having
132
found a bug, it's not easy to find what caused it. Where is the bad assumption
133
that got us into trouble? Some bugs are hell to track down. One crashing bug in
134
Outlook would reproduce only on a Gateway computer equipped with a Matrox video
135
card. Eventually, we tracked the bug down to one single line of code that
136
failed because it assumed all graphics cards are created equal. They are
137
not.
138
139
140
Bug fixing is time consuming. Developers must
141
review every line of code, one at a time. They often deploy programs called
142
"debuggers," which allow them to peer into the innards of the software as it
143
runs. As developers kill the bugs, they incorporate the solutions into a daily
144
"build" of the program and test the build to make certain the solutions don't
145
cause additional bugs. Outlook 97 went through several thousand builds before
146
it was released, each build bringing us infinitesimally closer to
147
perfection.
148
149
As we
150
approach perfection, though, the law of diminishing returns kicks in. Are the
151
existing bugs fatal defects, or can we live with them? We developers have a
152
name for bugs we can live with: "known issues." By the time Outlook 97 was
153
released in November 1997, I suspect I was intimate with every one of its known
154
issues. I also suspect that 99 percent of all bugs reported by users to
155
software companies have already been noted and prioritized for fixing by some
156
late-night team of code warriors.
157
158
The worst bug is a "show stopper" bug, the bug that will
159
croak the entire program. When a show stopper is discovered, we drop everything
160
and find a fix. But we make the absolutely smallest necessary change to kill
161
the bug so that the other parts of the system can continue to work, oblivious
162
to the chaos around them.
163
164
Developers
165
seek a balance between "it's done" and "it's perfect" when writing software.
166
But it's difficult to know when to stop. You are always only a few late nights
167
away from perfection. Where refining a 747 is, shall we say, somewhat involved,
168
software writing is powered on caffeine and little more. In fact, one
169
enterprising young developer strung out on Mountain Dew eventually fixed the
170
year 4500 bug in Outlook 98, making it safe for everyone making appointments in
171
the next several millenniums.
172
173
174
If you
175
missed our links in the article, click to read about why programmers created
176
the Y2K bug and for a "simple" program in C.
177
178
179
180
181
182
183