Exceptions and pre-conditions

From Computer Science Wiki
Jump to: navigation, search
Exceptionsanomalous or exceptional conditions requiring special processing – often changing the normal flow of program execution[1]

An exceptionanomalous or exceptional conditions requiring special processing – often changing the normal flow of program execution is an anomalous or exceptional condition requiring special processing – often changing the normal flow of program execution[2].

Be careful not to confuse an exceptionanomalous or exceptional conditions requiring special processing – often changing the normal flow of program execution with an error.

An error "indicates serious problems that a reasonable application should not try to catch." An Exceptionanomalous or exceptional conditions requiring special processing – often changing the normal flow of program execution "indicates conditions that a reasonable application might want to catch."[3].

We use the term "catch an exceptionanomalous or exceptional conditions requiring special processing – often changing the normal flow of program execution" to catch exceptionsanomalous or exceptional conditions requiring special processing – often changing the normal flow of program execution and plan how the program should respond.

Identifying exceptionsanomalous or exceptional conditions requiring special processing – often changing the normal flow of program execution

The exceptionsanomalous or exceptional conditions requiring special processing – often changing the normal flow of program execution below are common. There are many other types of exceptionsanomalous or exceptional conditions requiring special processing – often changing the normal flow of program execution.

  1. consider different data types (are you passing an int to a function which is expecting a string?)
  2. consider inaccurate user input (accidental or deliberate)
  3. consider writing or reading a to file - there could be a failure opening, writing, or closing to file
  4. consider memory limitations - this is especially important when you are working with large datasets
  5. consider the possibility a user might attempt to interrupt the program (usually by pressing control-C).

For a listGive a sequence of brief answers with no explanation. of common exceptionsanomalous or exceptional conditions requiring special processing – often changing the normal flow of program execution, please click here

Example

I am writing a program to calculateObtain a numerical answer showing the relevant stages in the working. your final grade. The program accepts as input your name, all your grades, averages them, and then outputs your name and a final score.

What exceptionsanomalous or exceptional conditions requiring special processing – often changing the normal flow of program execution might we consider?

  1. What if a student is missing a score?
  2. What if a score is non-standard (instead of an integerA natural number, a negative of a natural number, or zero., we have a letter)?
  3. What if a there is non-standard character in a student name?

Do you understand this?

Standards

These standards are used from the IB Computer Science Subject Guide[4]

  • IdentifyProvide an answer from a number of possibilities. Recognize and state briefly a distinguishing fact or feature. exceptionsanomalous or exceptional conditions requiring special processing – often changing the normal flow of program execution that need to be considered in a specified problem solution.

References

  1. http://www.flaticon.com/
  2. https://en.wikipedia.org/wiki/Exception_handling
  3. https://stackoverflow.com/questions/5813614/what-is-difference-between-errors-and-exceptions
  4. IB Diploma Programme Computer science guide (first examinations 2014). Cardiff, Wales, United Kingdom: International Baccalaureate Organization. January 2012.