Expectation of Exceptional Handling Errors / Exceptions
Course Overview and Homework Assignments
Midterm exam is scheduled for tomorrow.
Homework Five has been posted before Homework Four's due date.
Focus areas for Homework Five include:
Sets
Maps
Trees
Hash Tables
Knowledge checks have been posted (initially intended for the previous week).
Recommended to complete before the midterm, but due Friday.
Topics include iterators, sets, and maps.
Course Structure and Assignments
Total of six homeworks in the course:
Five already posted; one more larger assignment or project to follow.
Expectation is to tackle substantial material early, leading to a lighter load as the course progresses towards April.
Encouraged to engage with the posted materials to aid midterm preparation.
Student Questions and Topics
Instructor encourages student inquiries regarding covered topics or specific questions, including:
The
try catchblock.
Exception Handling in Programming
Definition of Exceptions: Exceptions are triggered during abnormal events or errors in a program that disrupt standard flow.
When to throw exceptions:
Correct Use: Only throw exceptions under truly exceptional circumstances (e.g., null nodes in data structures).
Incorrect Use: Avoid throwing exceptions for normal user input validation (e.g., negative numbers).
Example Scenario for Exceptions
Tree Data Structure:
Creating a tree object without any initial values.
If calling a method on this empty tree results in errors, throw exceptions indicating the absence of values.
Fraction Class Example:
To construct a fraction, both numerator and denominator are required.
If either is missing, the fraction class should throw a runtime exception stating the issue, e.g., ( ext{