Introduction to Programming Using Visual Basic 2005, An (6th Edition)
2.1. Program Development CycleWe learned in the first chapter that hardware refers to the machinery in a computer system (such as the monitor, keyboard, and CPU) and software refers to a collection of instructions, called a program, that directs the hardware. Programs are written to solve problems or perform tasks on a computer. Programmers translate the solutions or tasks into a language the computer can understand. As we write programs, we must keep in mind that the computer will only do what we instruct it to do. Because of this, we must be very careful and thorough with our instructions. Note: A program is also known as a project, application, or solution. Performing a Task on the Computer
The first step in writing instructions to carry out a task is to determine what the output should bethat is, exactly what the task should produce. The second step is to identify the data, or input, necessary to obtain the output. The last step is to determine how to process the input to obtain the desired output, that is, to determine what formulas or ways of doing things can be used to obtain the output. This problem-solving approach is the same as that used to solve word problems in an algebra class. For example, consider the following algebra problem: How fast is a car traveling if it goes 50 miles in 2 hours? The first step is to determine the type of answer requested. The answer should be a number giving the speed in miles per hour (the output). (Speed is also called velocity.) The information needed to obtain the answer is the distance and time the car has traveled (the input). The formula speed = distance/time is used to process the distance traveled and the time elapsed in order to determine the speed. That is, A pictorial representation of this problem-solving process is We determine what we want as output, get the needed input, and process the input to produce the desired output. In the following chapters we discuss how to write programs to carry out the preceding operations. But first we look at the general process of writing programs. Program Planning
A baking recipe provides a good example of a plan. The ingredients and the amounts are determined by what is to be baked. That is, the output determines the input and the processing. The recipe, or plan, reduces the number of mistakes you might make if you tried to bake with no plan at all. Although it's difficult to imagine an architect building a bridge or a factory without a detailed plan, many programmers (particularly students in their first programming course) try to write programs without first making a careful plan. The more complicated the problem, the more complex the plan may be. You will spend much less time working on a program if you devise a carefully thought out step-by-step plan and test it before actually writing the program. Many programmers plan their programs using a sequence of steps, referred to as the program development cycle. The following step-by-step process will enable you to use your time efficiently and help you design error-free programs that produce the desired output.
|
Категории