Type Here to Get Search Results !

BASIC PRINCIPLES OF COMPUTER PROGRAMMING

Introduction


Computer programming is both an art and a science. In this unit, we students shall be exposed to some arts and science of computer programming including principles of programming and stages of programming.

MUST READ:A

  1. computer hardware 
  2. computer application programming using visual basic 
  3. areas of application of computers 
  4. auxillary equipment
  5. assembling the entire system-computer
  6. basic principles of computer programming 
  7. cd rom failure – symptoms and troubleshooting
  8. classification of computers 
  9. computer applications in government, science, engineering, transport, communications, recreation and the military 
  10. computer applications in the bunesss and industry 
  11. computer languages 
  12. checking the power supply

Problem Solving With The Computer

The computer is a general-purpose machine with a remarkable ability to process information. It has many capabilities, and its specific function at any particular time is determined by the user. This depends on the program loaded into the computer memory being utilized by the user.

There are many types of computer programs. However, the programs designed to convert the general-purposes computer into a tool for a specific task or applications are called ‘Application programs’. These are developed by users to solve their peculiar data processing problems.

Computer programming is the act of writing a program which a computer can execute to produce the desired result. A program is a series of instructions assembled to enable the computer to carry out a specified procedure. A computer program is the sequence of simple instructions into which a given problem is reduced and which is in a form the computer can understand, either directly or after interpretation.

 Programming Methodology

Principles of good Programming
It is generally accepted that a good Computer program should have the characteristics shown below:
Accuracy: The Program must do what it is supposed to do correctly and must meet the criteria laid down in its specification.

Reliability:
The Program must always do what it is supposed to do, and never crash. Efficiency: Optimal utilization of resources is essential. The program must use the available storage space and other resources in such as way that the system speed is not wasted.

Robustness: The Program should cope with invalid data and not stop without an indication of the cause of the source of error.

Usability: The Program must be easy enough to use and be well documented. Maintainability: The Program must be easy to amend having good structuring and documentation.

Readability: The Code of a program must be well laid out and explained with comments.

Stages of Programming

The preparation of a computer program involves a set of procedure. These steps can be classified into eight major stages, viz
  1. Problem Definition 
  2. Devising the method of solution 
  3. Developing the method using suitable aids, e.g. pseudo code or flowchart. 
  4. Writing the instructions in a programming language 
  5. Transcribing the instructions into “machine sensible” form 
  6.  Debugging the program 
  7.  Testing the program 
  8. Documenting all the work involved in producing the program. 

 Problem definition


The first stage requires a good understand of the problem. The programmer (i.e. the person writing the program) needs to thoroughly understand what is required of a problem. A complete and precise unambiguous statement of the problem to be solved must be stated. This will entail the detailed specification which lays down the input, processes and output-required.

Devising the method of solution

The second stage involved is spelling out the detailed algorithm. The use of a computer to solve problems (be it scientific or business data processing problems) requires that a procedure or an algorithm be developed for the computer to follow in solving the problem.

Developing the method of solution

There are several methods for representing or developing methods used in solving a problem. Examples of such methods are: algorithms, flowcharts, pseudo code, and decision tables.

 Writing the instructions in a programming language

After outlining the method of solving the problem, a proper understanding of the syntax of the programming language to be used is necessary in order to write the series of instructions required to get the problem solved.

 Transcribing the instructions into machine sensible form

After the program is coded, it is converted into machine sensible form or machine language. There are some manufacturers written programs that translate users program (source program) into machine language (object code). These are called translators and instructions that machines can execute at a go, while interpreters accept a program and executes it line-by-line.
During translation, the translator carries out syntax check on the source program to detect errors that may arise from wrong use of the programming language.

Program debugging

A program seldomly executes successfully the first time. It normally contains a few errors (bugs). Debugging is the process of locating and correcting errors. There are three classes of errors.
  1. Syntax errors: Caused by mistake coding (illegal use of a feature of the programming language). 
  2.  Logic errors: Caused by faulty logic in the design of the program. The program will work but not as intended. 
  3. Execution errors: The program works as intended but illegal input or other circumstances at run-time makes the program stop. There are two basic levels of debugging. The first level called desk checking or dry running is performed after the program has been coded and entered or key punched. Its purpose is to locate and remove as many logical and clerical errors as possible. 

The program is then read (or loaded) into the computer and processed by a language translator. The function of the translator is to convert the program statements into the binary code of the computer called the object code. As part of the translation process, the program statements are examined to verify that they have been coded correctly, if errors are detected, a series of diagnostics referred to as an error message list is generated by the language translator. With this list in the hand of programmer, enters the second level of debugging is reached.

The error message list helps the programmer to find the cause of errors and make the necessary corrections. At this point, the program may contain entering errors, as well as clerical errors or logic errors. The programming language manual will be very useful at this stage of program development.

After corrections have been made, the program is again read into the computer and again processed by the language translator. This is repeated over and over again until the program is error-free.

 Program testing

The purpose of testing is to determine whether a program consistently produces correct or expected results. A program is normally tested by executing it with a given set of input data (called test data), for which correct results are known.

For effective testing of a program, the testing procedure is broken into three segments.
  1.  The program is tested with inputs that one would normally expect for an execution of the program. 
  2.  Valid but slightly abnormal data is injected (used) to determine the capabilities of the program to cope with exceptions. For example, minimum and maximum values allowable for a sales-amount field may be provided as input to verify that the program processed them correctly. 
  3. Invalid data is inserted to test the program’s error-handling routines. If the result of the testing is not adequate, then minor logic errors still abound in the program. The programmer can use any of these three alternatives to locate the bugs. 

Conclusion

The intelligence of a computer derives to a large extent from the quality of the programs. In this unit, we have attempted to present in some details, the principles and the stages involved in writing a good computer program.