Rules in Software Development
Would you be satisfied with a bank’s service if the bank lost 0.1% of your money every
day due to a software mistake? Would you accept a wrist watch that lost 40 minutes
every month? Both of these are cases of “99.9% success” but are nonetheless unacceptable.
Computers are now being used in many applications, some of which could affect human
safety. If your program works correctly 99.9% of the time, then your program could kill
people during the remaining 0.1%. This is totally unacceptable, and such a program is a
failure. Thus, 99.9% success is failure.
If you live in Pasadena, California, and want to go to New York, which route should you
take? Perhaps you could go to the Los Angeles Airport and take a flight. New York is at the
east side of Pasadena but the airport is at the west side of Pasadena. Why don’t you drive
(or even walk) east from Pasadena right away? Why do you travel farther than necessary
and go west of your destination to the airport? After one hour of travel, you would be close
to New York if you drove rather than waiting in lines at an airport. The answer is simple: An
airplane is a better tool than a car for long-distance travel. In program development, there
are many tools designed for managing larger programs. You need to learn these tools. Yes,
learning these tools takes time but you spend much more time when using inappropriate
tools, or not using any tool at all. Spending time learning programming tools can save time
in development and debugging.
Despite decades of effort, computers are still pretty “dumb”. Computers cannot guess
what is on your mind. If your programs tell a computer to do the wrong thing, then the
computers will do the wrong thing. If your program is wrong, it is your fault. Computers
cannot read your mind. There are many instances in which “small” mistakes in computer
programs cause significant financial damages, injuries, or loss of lives. Missing a single
semicolon (;) can make a C program unusable. Replacing . by , can also make a C program
fail. Computer programs c a nnot tolerate “small” mistakes.
Passing test c ases does not guarantee a pr ogram is correct. Testing can only tell you
that a program is wrong. Testing cannot tell you that a program is correct. Why? Can test
cases cover every possible scenario? Covering all scenarios is difficult and, in many cases,
impossible. Problems can be hidden inside your programs because it is difficult for test cases
to detect idiosyncratic behavior.
Producing correct outputs does not me an a program is corre ct. Would you consider a
plane safe if the plane has taken o and landed without any injuries? If the plane leaks fuel,
would you demand the airline fix the plane before boarding? Would you accept the airline’s
response “Nobody was hurt so this means that plane is safe.”? If a driver runs a red light
without an accident, does that mean running a red light is safe? A program that produces
correct outputs is like a plane that lands without injury. There may be problems beneath the
surface. Many tools are available to detect hidden problems in human health, for example
X-ray, MRI, and ultrasonic scan. To detect hidden problems in computer programs, we need
good tools. We need to fix programs even though they produce correct outputs.
You have to assume that your programs will fail and develop a strategy to detect and
correct mistakes. When writing a program, focus on one small part each time. Check it
carefully and ensure that it is correct before working on other small parts. For most pro-
xxix
xxx Rules in Software Development
grams, you need to write additional code for testing these small parts. You will save a lot
of time if you write additional testing code, even though the testing code is not included in
the final program. Sometimes, the testing code is more than the programs themselves. My
own experience suggests 1:3 ratio—for every line in the final program, about three lines of
testing code are needed.
No tools can replace a clear mind. Tools can help but nothing can replace deep and
thorough understanding of the concepts. If you want to be a good software developer, then
you need to fully understand every detail. Do not rely on tools to think for you: They
cannot.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset