Exception
Handling
Exception Handling in Goody's
"For
the presentation of the basic concepts of exception handling the
following scenario from the Goodys example is considered. Helen has
just accepted the message a sandwich with cheese and ham please.
Helen carries out the actions required to prepare the sandwich. The
response of Helen to this event is predictable since she was given
instructions on how to handle it.
Students are asked to consider the case in which there is no cheese
slices available. Even though this is an unusual event, i.e. an
exceptional case, there is still a possibility, even small, for this to
occur. The term exception is introduced to refer to the
exceptional case and students are asked to describe the behavior of
Helen to this exception. It is clear to all of them that if Helen was
not informed on how to identify and handle this exception, the system
will toggle to a state of undefined behavior. It is next assumed that
Helen is informed as to how to identify this exception and the following
two cases are considered:
-
Helen has the knowledge to carry out a set of actions to handle this
special event, and
-
Helen
has no knowledge of the actions required to cope with this special
event.
In the
first case Helen identifies the exception, catches the exception, and
executes the set of actions required to cope with it. There is no need
to notify the client or her supervisor about the exception. In the
latter case, Helen only has the knowledge required to identify this
special event but since her supervisor has not informed her how to
handle it, she only has to pass the required information to another
entity to cope with it. This entity should catch this information, the
exception object, and execute the required actions." [1]
(for more information see related
paper)
[1]
K.
Thramboulidis, A
Constructivism-based Approach to Teach Advanced Computing Concepts in
Introductory Java Courses,
Journal of Informatics
Education and Research (forthcoming).
Abstract
|