Ralph Morelli, Ralph Walde, Beryl Hoffman, David G. Cooper
Section1.2Designing Good Programs
Programming is not simply a question of typing Java code. Rather, it involves a considerable amount of planning and careful designing. Badly designed programs rarely work correctly.
Principle1.2.1.PROGRAMMING TIP: Design before coding.
The sooner you begin to type code, the longer the program will take to finish, because careful design of the program must precede coding. This is particularly true of object-oriented programs.
In other words, the more thought and care you put into designing a program, the more likely you are to end up with one that works correctly. The following subsections provide a brief overview of the program development process.
Subsection1.2.1The Software Engineering Life Cycle
Software engineering is the process of designing and writing computer programs, or, software. The software life cycle refers to the different phases in that process. Our presentation of examples in the book will focus on four phases of the overall life cycle.
Figure 1.2.2 gives a detailed overview of the software life cycle. It shows that designing an object-oriented program is largely a matter of asking the right questions about the classes, data, and methods that make up the program.
Overall, the programming process can be viewed as one that repeatedly applies the divide-and-conquer principle. That is, repeatedly divide the problem until you have a collection of relatively easy-to-solve subproblems, each of which can be handled by an object.
In this way the program is divided into a collection of interacting objects. For each object we design a class. And for each class, we divide it further into its variables and methods.
The answers to these and similar questions are not easy. Good answers require the kind of judgment that comes through experience, and frequently there is more than one good way to design a solution.