Lecture overview -- Keyboard shortcut: 'u'  Previous page: What is normal? What is exceptional? -- Keyboard shortcut: 'p'  Next page: When are errors detected? -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Help page about these notes  Alphabetic index  Course home  Page 5 : 30
Object-oriented Programming in C#
Exception Handling
Examples of normal and exceptional aspects

Normal aspects and exceptional aspects - anticipated or non-anticipated

  public static long Factorial(int n){
    if (n == 0)
      return 1;
    else return n * Factorial(n - 1);
  }

A recursive Factorial function.

1.   Negative input

2.   Wrong type of input

3.   Wrong type of multiplication

4.   Numeric overflow

5.   Out of memory

6.   Loss of power

7.   Machine failure

8.   Sun failure

/user/normark/oop-csharp-1/sources/c-sharp/factorial/fac3.csAn iterative Factorial function.


/user/normark/oop-csharp-1/sources/c-sharp/factorial/fac4.csAn iterative Factorial function with a precondition - not C# 3.0. This program is explained