Simple error handling techniques Flashcards
(11 cards)
What is data validation?
Necessary to ensure data is complete, falls within a set of boundaries or specified within the code and is sensible. It aims to reduce the amount of erroneous data captured by the program or the system.
Can be performed using length, presence, range, type and format checks
What does a presence check do?
Ensures the field is not left blank/null
What does a range check do?
Ensures that data entered is within the correct range. This is done through the use of upper and lower boundaries
What does a length check do?
Ensures the data entered does not exceed or is not shorter than a particular number of characters
What does type check do?
Ensures the data is of the correct data type?
What does a format check do?
Ensures data is entered in the correct format, this means the data must conform to a pattern
When can you detect a syntax error?
When the program is being compiled, a program with syntax errors will not compile
When can execution and run time errors be detected?
During program execution and will cause the program to crash
When can a logic error be detected?
During testing, the output wont match the expected output
What is debugging?
The process of detecting and correcting or removing errors from the code, you may have to go through code lines one at a time
What happens during exception/error handling?
The program will attempt to deal with an error generated at run time so that the program does not crash. When an error occurs, an exception is raised that “calls” code to handle the error. An un-handled exception will still cause the program to crash.