A computer program is a sequence of instructions that specifies computations and actions that a computer will carry out. Programming is a complex process. It can involve mathematical, symbolic, and logical operations. Often, programs are written in an object-oriented language.
There are three types of programming errors. These errors include syntax errors, runtime errors, and semantic errors. Syntax errors occur when the programmer writes code in a way that does not make sense to the computer. This error makes it impossible to interpret the program.
An example of a syntax error is the use of quotation marks to begin a value. While the sentence, “Are you how?” is correct, it does not have a valid syntax. When you encounter a syntax error, you must identify and fix it.
Unlike a syntax error, a runtime error does not appear until the program runs. However, it does indicate a bad event. Therefore, you should always debug your program to keep it working.
The syntax of a program is the proper ordering of symbols. The order of the instructions is important, as it helps the computer understand them. In a formal language, this is more difficult. You should learn to parse the program in your head, rather than simply read it.
Another type of error is ambiguity. Sometimes, an ambiguity is intentional. For example, a module might have two functions, which both have the same name. To avoid this, the module should be named after the function that it performs.
Object-oriented languages have a structure that is designed to make programming easy. This is done by having global variables, which are seen by every other function in the source code. Similarly, static variables have addresses that are set at compile time.
Using a data-flow diagram to represent the process of a program helps you visualize how the program is run on the computer. Several standards exist for flowcharting.
Having a data-flow diagram for your program also helps you create a data-coupling module, which does not modify the input parameters of the function. Typically, a data-coupling module requires all the input parameters to be the same. If the input parameters are different, then a separate function will be required.
Program translation is a process that involves the converting a high-level program into a low-level program. Often, this is done by an interpreter. As the program is executed, the interpreter reads the high-level program and converts it into an intermediate form. From this intermediate form, the program is then translated into byte code, which is then interpreted by a virtual machine. Once byte code has been translated into object code, it is then compiled into a final program.
Object-oriented programming allows you to use global variables, which have addresses set at compile time. This means that the value will be retained for the life of the process. Moreover, you can reuse a compiled program without having to translate it.
Unlike a syntax error, an ambiguity error occurs when there is a relationship between the names of the modules. For example, the function compute_square_root_by_division(x) is not a good name for a module. Instead, a module that has a series of functions called compute_square_root_integer(i) is a better choice.