> How to Fix Errors in Programs

How to Fix Errors in Programs

Posted on Wednesday, November 14, 2012 | Comments Off





Syntax Error
1. Open the program’s source code.
2. Compile and run the program. Compilation is a process of translating the program into machine language. When syntax errors are found, the program will stop running and highlights the section of the code with the error.

3. Locate where the error occurs. If your program has thousands of lines of code, you can have more than one syntax error to fix.
4. Correct the error by replacing the incorrect “word” or “text” to conform to the grammar rules of the programming language you use. For example if a VB6 program highlighted the word “lblName.cption,” change the text to “lblName.Caption.”
5. Correct the rest of the errors found in other sections of the program code.
6. Save the changes you made by clicking the “Save” button from the toolbar or pressing “Ctrl S” from the keyboard.
Logical or Semantic Error
7. Run the program. Logical errors usually occur during calculation of values. For example, a program that computes the age of a person by inputting a birth date and comparing it to current date may produce a wrong result if the algorithm is written inaccurately.
8. Input sample values to the entry fields in the program interface. Click the button that triggers the calculation of values.
9. Check the accuracy of the results. Since logical errors are hard to catch because a program may still run without interruption, it is vital that the programmer pays close attention to how he manipulates the data through the code he writes.
10. Correct the algorithm or formula in the source code.
11. Compile and run the program. Repeat steps 2 and 3 to make sure the error is fixed. Save the changes you made by clicking “Save” button from the toolbar or pressing “Ctrl S” from the keyboard.
Run Time Error
12. Run the program and use its features as a user would. For example, in a data entry program, you may input values to fields and save the information into a database. Providing a wrong data type for an input, such as typing a “date” value into a “text” field may trigger a run time error.
13. Identify the type of error that shows up. Usually, run time errors have corresponding number associated with it so a programmer can find other sources of information about the error to fix it.
14. Rewrite the code to fix the problem. In the example in Step 1, you can prevent that particular run time error from happening again by writing a code that validates the input data before saving them into the database.
15. Save the changes you made by clicking “Save” button from the toolbar or pressing “Ctrl S” from the keyboard.

Powered by Blogger.