Wednesday 12 March 2014

Error Handling

Error Handling 

Error Handling –  Even if you write the neatest, tidiest code in the history of computing and test it to within an inch of its sorry life, there may well come a time when a programme user comes across a bug or an error that you didn’t foresee.
Remember that because you already have the advantage of having written such fabulously neat code, it should be relatively easy to follow the paths to find the glitch. Plus, an error will be in one of three categories: it’s either a syntax error, a run-time error, or it’s a logic error.
Let’s walk through these one at a time.
A syntax error is simply a mistake in the way the code has been written. Imagine that in an essay you write “there is five locations” by mistake. The error in syntax is the singular “is” when it should be the plural “are” to match the plural noun. You’ve made an error in the rules of grammar, just as a syntax error in computing is an error in the rules of computer language grammar. Maybe there’s a lower case letter where it should be an upper case, or a bracket hasn’t been closed. Yup, it can be something as annoyingly small as that.
Then we have run-time errors. These occur while a programme is running, and is usually due either to programmer error, or perhaps some of the code is shared with another programme running at the same time and they decide they don’t like working together. It might even be malware if the programme has been infected by a virus or a Trojan has managed to sneak in.
Lastly there are logic errors. Remember we talked about logical data structures being based on yes/no or true/false? These really are down to you and you can’t blame the dog or alien invasion because it’s you who sets up the yes/no true/false dialogues. Unfortunately these are usually the trickiest to fix if you haven’t understood that what you wrote was an error.
So what can you do to prevent errors as much as possible? Prevention is always better than cure, right, so thorough testing is crucial during the design stage and while you’re writing the coding. Errors can creep in if you’re getting tired and bored, so develop the eyes of an eagle, give yourself breaks from the screen to refocus, and concentrate while you’re writing code.

No comments:

Post a Comment

Wildern Pupils if you log onto your school email account you can leave a comment via that ID.