- Assertions are for debugging. The user of your shipped code should never see them. If an assertion is hit, your code needs to be fixed.
- Exceptions are for exceptional circumstances. If one is encountered, the user won't be able to do what she wants, but may be able to resume somewhere else.
- Error handling is for normal program flow. For instance, if you prompt the user for a number and get something unparsable, that's normal, because user input is not under your control and you must always handle all possible situations as a matter of course. (E.g. loop until you have a valid input, saying "Sorry, try again" in between.)
Assertion, exception and error handling
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment