Correctness, Robustness, Efficiency
In previous chapters, we have covered programming fundamentals. The chapters that follow this one will cover more advanced aspects of programming. The ideas that are presented will generally be more complex and the programs that use them a little more complicated. This relatively short chapter is a kind of turning point in which we look at the problem of getting such complex programs right.
Computer programs that fail are much too common. Programs are fragile. A tiny error can cause a program to misbehave or crash. Most of us are familiar with this from our own experience with computers. And we've all heard stories about software glitches that cause spacecraft to crash, web sites to go offline, telephone service to fail, and, in a few cases, people to die.
Programs don't have to be as bad as they are. It might well be impossible to guarantee that programs are problem-free, but careful programming and well-designed programming tools can help keep the problems to a minimum. This chapter will look at issues of correctness and robustness of programs. Section 8.2 discusses how you can think about and analyze programs to make the programs that you write more likely to be correct—possibly even provably correct.
In Section 8.5, we look at another issue that is important for programs in the real world: efficiency. Even a completely correct program is not very useful if it takes an unreasonable amount of time to run. The last section of this chapter introduces techniques for analyzing the run time efficiency of algorithms.
Some of the topics in this chapter are the topics of advanced courses in computer science, and only a brief overview can be given here. But what you do learn here will be useful in the rest of the book.