Hello friends, in this article you will gather knowledge about one of the most important topics in programming i.e. Testing and Debugging, Syntax and Semantics, and Error and its types. This is one of the most important topics that everyone should know.

Testing and Debugging

All programs are not perfect as long as human creates them. Program errors are known as bugs, and the process of detecting, locating, and correcting these errors is called debugging. In general, testing is the process of making sure that the program performs the intended task, and debugging is the process of locating and eliminating program errors. Testing and debugging are important steps in program development. They are also time-consuming steps. In fact, for large programs, the time spent in testing and debugging often exceeds the time spent coding the program. It is good practice to test each component of a program as it is produced as well as testing the completed program.
There are several stages of testing:
  • Unit testing, which involves testing the individual components.
  • Integration testing, which involves testing the separate components as they are put together.
  • System testing, which involves testing the whole program.
  • User acceptance testing, which involves the user testing the program to see that it is what is required.

Syntax and Semantics

As we know, programming language helps us to communicate with the computer, which is governed by a set of codes that a computer programmer writes to instruct the computer hardware to perform specified tasks. These codes are governed by a set of rules called syntax. In other words, it is the set of rules for combining the elements of a programming language into permitted instructions. In addition to this, semantics is the meaning attached to individual words or symbols in the programming language. It is the logic or concept or idea of the program.

Error (BUG)

Errors are mistakes in the program. The error can be in the syntax or logic (concept/ idea) of the program. If a program contains an error, it will either not produce output or may produce inaccurate output. The process of detecting and correcting the error is known as debugging.
Different types of errors are:
  • Syntax error
  • Logical error (a semantic error)
  • Run time error

Syntax Error

A syntax error is an error in the syntax or format of the program. It happens when it does not conform to the syntax of the programming language. For example in C language, whenever we do not use the semicolon in a simple statement causes a syntax error. It is detected by a language translator at the translator process. if a program contains a syntax error, it is not translated into the object code. So, it will not be executed and will not produce output. This type of error is easier, faster, and cheaper to debug. Experienced personnel is not required. Reference materials like help files, books, and documents are available for correcting the syntax of the program.

Logical Error (Semantic Error)

A logical error is an error in a logic/ concept/ idea of the program that causes it to operate incorrectly but not to terminate the program abnormally. It is not detected by a language translator during the translation process. If a program contains only the logical error, it is translated into the object code, executed, and also produces output. However, the output may not be accurate. A semantic error produces undesired output due to an error in the program’s logic. For example, to calculate the simple interest, the formula is i = (p*t*r)/100 but if we write i = (p*t*r)/10 then it will produce a semantic error because it is syntactically correct but it produces undesired output. This type of error is difficult, slower, and expensive to debug. Experience personnel is required for debugging the program. Reference materials are usually not available for the logic of the program.

Run-Time Error

When a program is running or executing, it is said to be in runtime. A runtime error is an error that happens while the program is executing. For example, a memory leak, where the program takes up excessive amounts of system memory is also a runtime error; peripheral devices may not be turned on. If a program contains only the runtime error, it is not detected by the translator. So, it will be translated into the object code and the execution will start. However, execution may not be completed and may not produce output.
Testing and Debugging, Syntax and Semantics and Types of Error (BUG) - ComputeNepal
Testing and Debugging, Syntax and Semantics and Types of Error (BUG)

Similar Posts

Leave a Reply

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