Structured programming leads to Error Avoidance

By Youssef Edward
March 16, 2019

Expert programmers tend to follow some practice in order to avoid common errors. This is like avoiding certain control commands. Although allocated to be used by the used language, it is a best practice to avoid them. Some common command that lead to errors is the Goto statement. Using jump instructions such as while and if is better than the Goto statement.

The cause that Goto statement is error prone is that the sequence of the program is partially lost. This is happened either during the program development or while revising the program. Hence they are likely to make a mistake during development. Avoiding unsafe control statements is the first step in programming for reliability.

In addition to the Goto statement, there are other ways to program reliably without error. Those are as follow:

  1. Floating Point numbers: those numbers are not precise. They impose a problem during comparison with the operators (>,<,>=,<=). This is because of the complicated binary representations. Fixed point numbers are safer to use.


  1. Pointers: Pointers only refer to areas in the memory holding the variables. They are dangerous because errors in their use can be devasting and because they allow aliasing. This means the same entity may be referenced using different names. Aliasing make programs harder to understand so that errors are more difficult to find. However, efficiency requirements mean that it is impractical to avoid the use of pointers.


  1. Dynamic memory allocation: in this technique, the program memory is allocated in run time not in compile time. This means it depends on the available memory on computer at the time the program run. If the available memory gets low, the program can halt. This can happen after developing the program successfully and after long time.


  1. Parallelism: it is dangerous because it is difficult to predict the timing between two concurrent processes. Also the outcome of one running process may depend on thee outcome of another process that still running. Timing problems cannot be detected by program insection and the problems imposed by timing parallelism may not happen during program testing. It is recommended to avoid parallelism as possible. However, they offer more speed in data processing.
  2. Recursion : recursion is the technique by which a subroutine calls it self again and again. It is better to avoid it for to reasons. First, the program flow is difficult to follow. Second, and more important is because the program stack may get full to great level and cause all the computer memeory to overflow. In that case, the computer will halts. This is because on each new recursion, the temporary variable associated with the current rcurse level is stored. If the routine use only two variables, and the routine is called 100 times from itself, it will mean there are 200 temporary variables in the routine that need to be stored on the stack.


  1. Interrupts: interrupts are accidental jump to a certain area in memory that handles the specified event. The danger of it is that it may halt critical operation that is running. Also, it may result in data corruption. This happened if non atomic instructions are interrupted while the data still be updated in its registers. If the interrupt routine read the data while not updated completely, data integrity will be lost.

Leave a Reply

Your email address will not be published. Required fields are marked *