[Skip Navigation] [CSUSB] / [CNS] / [Comp Sci & Eng] / [R J Botting] /[CS320 Course Materials] /17.html [17.txt(Text)] [Search ]
Tue Jun 1 14:10:52 PDT 2010
[Schedule] [Syllabi] [Text] [Labs] [Projects] [Resources] [Grading] [Contact]
Notes: [01] [02] [03] [04] [05] [06] [07] [08] [09] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20]

Contents


    CS320/17 Exception and Event Handling and Chapter 14


      Table
      Prev 16Concurrency and JavaChapter 13 not sect'n 9lab16 Java102
      17ExceptionsChapter 14lab17 Java103
      Next 18PrologChapter 2 sect'n 13 + Prolog Handoutlab18 Prolog101

      (Close Table)

      Preparation

    1. Study chapter 14 and these notes. Focus on C++ and Java exceptions.
    2. Answer review questions at the end of the handout
    3. Hand in answers to 2 or more review questions.

      Key ideas to remember:

      1. exception
      2. handling an exception
      3. exception handler
      4. raising an exception
      5. disabling an exception
      6. built in exception
      7. event
      8. event handler

      Don't memorize all the exceptions and event types in Java. These details are needed to develop code, not on the final. Instead book-mark(put in favorites) the online WWW documentation [ index.html ] that Sun maintains.

      The CSci202 book "Scansholm" and Bjarne Stroustroup's LRM make a useful reference for C++ programmers. They won't be on the final.

      Exception Handling Principles

    4. Convert_exceptions::=If you can not handle an exception then convert it to a higher level exception.
    5. Name_the_problem_not_the_thrower::=name exceptions to indicate what is wrong not where it came from.
    6. centralize_error_logging::pattern. Have a single object that is responsible for recording bad things.
    7. standard_error_dialog::pattern. Have a standard user interface for reporting and sorting out errors.

      Notes on Chapter 14

      Event handling arrived late in the computer languages but is now a vital part of programming(Section 14.6.2...). GUIs (14.6.1) are easier than they look!

      Exceptions are not a late arrival. They are natural way to cope with Murphy's Law: If anything can go wrong, it will.

      Note. History of C++/Java exceptions. The throw and catch terminology comes form ..... CLOS LISP.

      Exceptions in Java (Missing point in book)

      The book does not mention a property of RuntimeException in Java. Normally the compiler rejects code that fails to catch a thrown Exception and doesn't declare that it throws it. This is not true of RuntimeExceptions. A welcome relief. You should spend some time in next sessions's lab exploring the Throwable hierarchy [ Throwable.html ] in Sun's documentation.

    Class Work

    [ 17q.html ]

    Lab Work

    [ lab/17.html ]

    Next

    [ 18.html ]

End