Writing error-free codeErrors and documenting code
When writing programs, code should be as legible and error free as possible. Debugging helps keep code free of errors and documenting helps keep code clear enough to read.
When programs are written, it is likely that at least some errors will creep in. Errors in programs are often referred to as bugAn error in a program..
It is vital that programs are as free of errors as possible. Errors can cause a program to produce unexpected results, or crashWhen an application or operating system no longer responds. Crashes can be caused by software and hardware..
There are two types of error that need to be considered:
syntax errorAn error in a programming language caused by not using the correct syntax. These are normally spelling errors or small grammatical mistakes.
Logic errorA fault in the logic or structure of the problem.
Each type of error is different, and each is solved in different ways.
It is also good practice to documentingMaking code easier to understand by giving meaningful names for variables, procedures and functions and by adding comments to explain the purpose of instructions. code. Documentation helps keep code easy to read and easy to understand.