Thinking About Programs
In this chapter, you will learn the following:
Five programming steps
UML class diagrams
The purpose of this chapter is to introduce you to program design. Over the years, many formal program design methodologies have been developed. Some of these design methodologies are relatively complex, whereas others are fairly simple. In all cases, however, the goal was the same: to help the programmer write programs that were easy to write, debug, and maintain.
In this chapter, we'll begin our program design discussion with a very simple design methodology. Although this simple methodology is fairly basic, it serves the purpose of starting you to think about the design of a program. After you've studied this simple methodology, I'll present a more formal methodology called UML. UML is a popular design methodology especially suited for object-oriented programming.
Each semester, I see the same thing happen. I assign a lab problem to the class. Within seconds, there's a clickety-clack of keystrokes as the students start typing in the code to solve the problem at hand. Invariably, however, there's one student who takes out a piece of paper and starts writing "stuff" on the paper. Minutes pass, but eventually the student starts typing program code into the computer. Almost without exception and despite the late start, that student finishes the assignment faster and with a better solution than does the rest of the class. Why?
If you look at the "stuff" the student wrote on the paper, you would find it's a program design for the problem. Some students have fairly elaborate designs filling up several pieces of paper, whereas other designs are fairly terse. The important thing, however, is that these students have a program design.