09 Error handling and testing Flashcards

(9 cards)

1
Q

How do we minimise the number of bugs and user mistakes in our program?

A

Careful engineering of a program
Error checking
Extensive automated testing

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How do modern softwares run tests on programs?

A

Continuous integration
Suite of tests run every time a change is made to the code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the two types of program errors?

A

Syntax errors
Exceptions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Syntax errors

A

Syntax does not conform to the rules of the language
Easy to detect as interpreter/compiler will print an error

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Exceptions

A

Something unexpected or anomalous occurs when executing a program

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are some examples of exceptions

A
  • Attempting to divide by 0
  • Receiving negative data when only positive data is permitted
  • Unexpected integer overflow
  • Attempting to compute the dot product between vectors of different lengths
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Raising/ Throwing an exception

A

Trigger an exception

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Parameter validity checking

A

Adding checks to parameter so we do not compute completely wrong answer
if r <= 0:
raise ValueError(“Distance r must be greater than zero”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Why is testing important

A

Enhances program quality
Building confidence in programming

How well did you know this?
1
Not at all
2
3
4
5
Perfectly