Computer programmers are familiar with errors in programs. Alternately referred to as "bugs," programming errors often surface all throughout the development stages of designing a software. There are three types of program errors commonly encountered and fixed by a programmer. Syntax errors result from writing the codes that do not conform to the programming language grammar. They are easy to spot and correct since the development software will identify them during compilation. Logical or semantic errors occur when a programmer writes a wrong algorithm or formula and the expected output is incorrect. Run time errors commonly show up during program execution when a user inputs data that are impossible to execute.
Things You'll Need:
- Computer
- Programming software
- Step 1
Open the program's source code.
- Step 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.
- Step 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.
- Step 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."
- Step 5
Correct the rest of the errors found in other sections of the program code.
- Step 6
Save the changes you made by clicking the "Save" button from the toolbar or pressing "Ctrl + S" from the keyboard.
- Step 1
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.
- Step 2
Input sample values to the entry fields in the program interface. Click the button that triggers the calculation of values.
- Step 3
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.
- Step 4
Correct the algorithm or formula in the source code.
- Step 5
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.
- Step 1
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.
- Step 2
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.
- Step 3
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.
- Step 4
Save the changes you made by clicking "Save" button from the toolbar or pressing "Ctrl + S" from the keyboard.
No comments:
Post a Comment