It's just a simple matter of programming. ”Any boss who has never written a program Programming is more than just writing code. Software has a life cycle. It is born, grows up, becomes mature, and finally dies, only to be replaced by a newer , younger product. Understanding this cycle is important because as a programmer you will spend only a small amount of time actually writing new code. Most programming time is spent modifying and debugging existing code. Software does not exist in a vacuum ; it must be documented, maintained , enhanced, and sold. In this chapter we take a look at a small programming project using one programmer. Larger projects that involve many people are discussed in Chapter 23 . Although the final code is fewer than a hundred lines, the principles used in its construction can be applied to programs with thousands of lines of code. Figure 7-1 illustrates the software life cycle. Figure 7-1. Software life cycle The major steps in making a program are: - Assignment
-
It all starts when someone gets a bright idea. Then they usually assign someone else to implement it. - Requirements
-
Programs start when someone gets an idea and assigns you to implement it. This is written down in a requirements document, which describes, in very general terms, what is wanted. - Specification
-
This is a description of what the program does. In the beginning, a Preliminary Specification is used to describe what the program is going to do. Later, as the program becomes more refined, so does the specification. Finally, when the program is finished, the specification serves as a complete description of what the program does. - Code design
-
The programmer does an overall design of the program. The design should include major algorithms, class definitions, module specifications, file formats, and data structures. One thing cannot be over-stressed: Think before you act. Studies have shown that a good design can result in a program that is one tenth the size of a poorly designed one. This is especially true when using C++, where designing good objects is critical to writing a good program. (You will find out what objects are in Chapter 13.) Note: "Think before you act" is good advice not only for coding, but also for life in general. See Chapter 26 for information on code design techniques. - Coding
-
The next step is writing the program. This involves first writing a prototype and then filling it in to create the full program. - Testing
-
The programmer should design a test plan and use it to test the program. This is the first level of testing. The next level involves having someone else test the program. Testing can result in bug reports , which means that you need to do some debugging. It can also uncover flaws in the original specification, in which case you need to review the results and see if a revised specification is needed. Finally, testing can show the absence of bugs. (Experienced programmers never say a program works; they say only that it has no observed bugs.) When testing shows that the number of bugs is acceptably low, the software is released. - Debugging
-
Unfortunately, very few programs work the first time. They must be corrected and tested again. - Release
-
The program is packaged, documented, and sent out into the world to be used. - Maintenance
-
Programs are never perfect. Bugs will be found and will need correction. - Revising and updating
-
After a program has been working for a while, the users will want changes, such as more features or more intelligent algorithms. At this point, a new specification is created and the process starts again. |