Custom Search
 
  

 
Coding a Program

Regardless of the language used, there are strict rules the programmer must adhere to with regard to punctuation and statement structure when coding any program. Using the programming flowchart introduced earlier, we have now added a program coded in BASIC to show the relationship of the flowchart to the actual coded instructions (fig. 1-6). Dont worry about complete understanding, just look at the instructions with the flowchart to get an idea of what coded instructions look like.

You will have to have specific information about the computer you are to use and how the language is implemented on that particular computer. The computer manufacturers provide these specifics in their users manual. Get a copy and study it before you begin to code. to you, but they may prevent your program from running.

Once coding is completed, the program must be debugged and tested prior to implementation.

Debugging

Errors caused by faulty logic and coding mistakes are referred to as "bugs." Finding and correcting these mistakes and errors that prevent the program from running and producing correct output is called "debugging." Rarely do complex programs run to completion on the first attempt. Often, time spent debugging and testing equals or exceeds the time spent in program coding. This is particularly true if insufficient time was spent on problem definition and logic development. Some common mistakes which cause program bugs are: mistakes in coding punctuation, incorrect operation codes, transposed characters, keying errors and failure to provide a sequence of instructions (a program path) needed to process certain conditions. To reduce the number of errors, you will want to carefully check the coding sheets before they are turned in for keying. This process is known as "desk-checking" and should include an examination for program completeness.

Typical input data should be manually traced through the program process-ing paths to identify possible errors. In effect, you will be attempting to play the role of the computer. After the program has been desk-checked for accuracy, the program is ready to be assembled or compiled. Assembly and compiler programs prepare your program (source program) to be executed by the computer and they have error diagnostic features which detect certain types of mistakes in your program. These mistakes must be corrected. Even when an error-free pass of the program through the assembly or compiler program is accomplished, this does not mean your program is perfected. However, it usually means the program is ready for testing.

Testing

Once a program reaches the testing stage, generally, it has proven it will run and produce output. The purpose of testing is to determine that all

Figure 1-6.Programming Flowchart and Coded Program.

data can reprocessed correctly and that the output is correct. The testing process involves processing input test data that will produce known results. The test data should include: (1) typical data, which will test the commonly used program paths; (2) unusual but valid data, which will test the program paths used to process exceptions; and (3) incorrect, incomplete, or inappropriate data, which will test the programs error routines. If the pro-gram does not pass these tests, more testing is required. You will have to examine the errors and review the coding to make the coding corrections needed. When the program passes these tests, it is ready for computer implementation. Before computer implementation takes place, documenta-tion must be completed.







Western Governors University
 


Privacy Statement - Copyright Information. - Contact Us

Integrated Publishing, Inc. - A (SDVOSB) Service Disabled Veteran Owned Small Business