next up previous
Next: Summary Up: Introduction to C++ Programming Previous: Multiple Choice Questions


Preparing a Computer Program

There are various steps involved in producing a computer program for a particular application. These steps are independent of which computer or programming language that is used and require the existence of certain facilities upon the computer. The steps are:

  1. Study the requirement specification for the application. It is important that the requirements of the application should be well specified. Before starting to design a program for the application it is necessary that the requirement specification is complete and consistent. For example a requirement specification that says `write a program to solve equations' is obviously incomplete and you would have to ask for more information on `what type of equations?', `how many equations?', `to what accuracy?' etc.
  2. Analyse the problem and decide how to solve it. At this stage one has to decide on a method whereby the problem can be solved, such a method of solution is often called an Algorithm.
  3. Translate the algorithm produced at the previous step into a suitable high-level language. This written form of the program is often called the source program or source code. At this stage the program should be read to check that it is reasonable and a desk-check carried out to verify its correctness. A programmer carries out a desk-check by entering a simple set of input values and checking that the correct result is produced by going through the program and executing each instruction themselves. Once satisfied that the program is reasonable it is entered into the computer by using an Editor.
  4. Compile the program into machine-language. The machine language program produced is called the object code. At this stage the compiler may find Syntax errors in the program. A syntax error is a mistake in the grammar of a language, for example C++ requires that each statement should be terminated by a semi-colon. If you miss this semi-colon out then the compiler will signal a syntax error. Before proceeding any syntax errors are corrected and compilation is repeated until the compiler produces an executable program free from syntax errors.
  5. The object code produced by the compiler will then be linked with various function libraries that are provided by the system. This takes place in a program called a linker and the linked object code is then loaded into memory by a program called a loader.
  6. Run the compiled, linked and loaded program with test data. This may show up the existence of Logical errors in the program. Logical errors are errors that are caused by errors in the method of solution, thus while the incorrect statement is syntactically correct it is asking the computer to do something which is incorrect in the context of the application. It may be something as simple as subtracting two numbers instead of adding them. A particular form of logical error that may occur is a run-time error. A run-time error will cause the program to halt during execution because it cannot carry out an instruction. Typical situations which lead to run-time errors are attempting to divide by a quantity which has the value zero or attempting to access data from a non-existent file.

    The program must now be re-checked and when the error is found it is corrected using the Editor as in (3) and steps (4) and (5) are repeated until the results are satisfactory.

  7. The program can now be put into general use - though unless the testing was very comprehensive it is possible that at some future date more logical errors may become apparent. It is at this stage that good documentation produced while designing the program and writing the program will be most valuable, especially if there has been a considerable time lapse since the program was written.



Subsections
next up previous
Next: Summary Up: Introduction to C++ Programming Previous: Multiple Choice Questions
Peter JB King
1999-08-31