How do we minimise the number of bugs and user mistakes in our program?
Careful engineering of a program
Error checking
Extensive automated testing
How do modern softwares run tests on programs?
Continuous integration
Suite of tests run every time a change is made to the code
What are the two types of program errors?
Syntax errors
Exceptions
Syntax errors
Syntax does not conform to the rules of the language
Easy to detect as interpreter/compiler will print an error
Exceptions
Something unexpected or anomalous occurs when executing a program
What are some examples of exceptions
Raising/ Throwing an exception
Trigger an exception
Parameter validity checking
Adding checks to parameter so we do not compute completely wrong answer
if r <= 0:
raise ValueError(“Distance r must be greater than zero”)
Why is testing important
Enhances program quality
Building confidence in programming