COMPSCI 1MD3 Lecture Notes - Lecture 13: Defensive Programming, Unit Testing

44 views2 pages

Document Summary

Debugging - trying to fix a program that you already know has a bug. You need a test case that reliably fails. Try to understand the internal state of the algorithm. To understand the internal state of the program. Use print statements to print out potentially relevant variables. Use a debugger to step through the program. Works with the editor to inspect source code and the internal state, while the program is running. Set breakpoints - run the source code until a particular line and then inspect it. Can step through each line of source code one at a time. Right click on a part of the code to set a breakpoint. Suppose you made a function that returns the max value. Suppose the input is not the right type. Allow python to deal with situations that aren"t well defined, or violates some condition. Python may interrupt the normal flow of execution.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents