Optimization of Exception Handling - PowerPoint PPT Presentation

1 / 23
About This Presentation
Title:

Optimization of Exception Handling

Description:

Optimization of Exception Handling. Kris Hjelmeland. Introduction. Why is exception ... An exception is a computational state that requires an extraordinary ... – PowerPoint PPT presentation

Number of Views:27
Avg rating:3.0/5.0
Slides: 24
Provided by: krishje
Category:

less

Transcript and Presenter's Notes

Title: Optimization of Exception Handling


1
Optimization of Exception Handling
  • Kris Hjelmeland

2
Introduction
  • Why is exception handling important?

3
What is Exception Handling?
  • An exception is a computational state that
    requires an extraordinary computation.
  • A handler is a code fragment that deals with an
    exception occurrence.

4
Strategies for Handling Exceptions
  • Take Control so program can continue
  • Throw for handling elsewhere
  • Ignore the problem altogether

5
Exception Handling in Languages
  • Languages like C, return a value from a function
    call.
  • Java and C use exception handling mechanisms.

6
Java Exception Handling in the JVM
  • Exception is thrown
  • JVM searches table for handler
  • System branches to handler
  • If handler not found
  • Search continues up hierarchy
  • Thread will terminate if an appropriate handler
    does not exist

7
Exception Handling Techniques
  • Return Code
  • if(returnvalue errorvalue)
  • //do error handling
  • Status Flag

8
Drawbacks of Older Techniques
  • Dependent on programmer
  • Requires timely error checking
  • Reduces readability
  • Error checking omissions

9
Goals of an Exception Handling Mechanism
  • Alleviate testing throughout the program
  • Prevent incomplete operations from continuing
  • Allow for the adding, changing, and removing of
    exceptions

10
Optimization of EHM
  • Suggested EHM Requirements
  • Appropriate Handling Models
  • Integration of Optimal Features

11
Suggested EHM Requirements
  • Reusability
  • Encapsulation
  • Totality
  • Consistency
  • Readability

12
Reusability
  • Object-oriented design provides reusability
  • Most software components are reusable
  • Reusability saves time and resources.

13
Encapsulation
  • Encloses data, methods, and definitions in a
    class capsule
  • Separates the interface from the definition
  • Helps provide better readability and reusability

14
Totality
  • Must detect all different types of errors
  • Must protect against all state and timing errors
  • Solutions need to encompass the entire program.

15
Consistency
  • Program should return to its original state after
    an error
  • All resources should be cleaned up after an
    exception terminates
  • Shared data and resources must be maintained

16
Readability
  • Exception handling should not cause errors
    because of messy code
  • Separating the exception handling code from main
    execution code is optimal.

17
Inadequate Readability
  • int error_value -1
  • if(functionCall1() error_value)
  • //fix the error
  • if(functionCall2() error_value)
  • //fix the error
  • if(functionCall3() error_value)
  • //fix the error

18
Adequate Readability
  • try
  • functioncall1()
  • functioncall2()
  • functioncall3()
  • catch(Exception e)
  • //fix the error

19
Handling Models
  • Termination Model
  • An alternative operation to its guarded block
  • Resumption Model
  • Very similar to a routine or method call

20
Optimal Features
  • Catch-any and Reraise
  • Pass exception to an appropriate place
  • Derived Exceptions
  • Allows for a hierarchy of exceptions
  • Exception Parameters
  • Pass data along to the handler

21
Conclusion
  • The optimization of exception handling
    affectively returns life to normal.

22
References
  • Borger, E. and Schulte, W. "A Practical Method of
    Specification and Analysis of Exception Handling
    - A Java/JVM Case Study," IEEE Transactions on
    Software Engineering, vol. 25, no. 9, September
    2000.
  • Buhr, B. A. and Russell Mok, W. Y., "Advanced
    Exception Handling Mechanisms," IEEE Transactions
    On Software Engineering, vol. 26, no. 9,
    September 2000.
  • Knudsen, J., L. "Exception Handling Versus Fault
    Tolerance," Exception Handling in Object Oriented
    Systems Workshop at ECOOP'2000, June 12, 2000.
  • Lang, J. and David, S. B., "A study of the
    applicability of existing exception handling
    techniques to component-based real-time software
    technology," ACM Transactions on Programming
    Languages Systems, vol. 20, no. 2, p. 274,
    March 1998.
  • Maxion, R. A. and Olszewski, R. T., "Eliminating
    Exception Handling Errors with Dependability
    Cases A Comparative, Empirical Study," IEEE
    Transactions on Software Engineering, vol. 25,
    no. 9, September 2000.
  • Mikhailova, A. and Romanovsky A.,
    "Behavior-Preserving Evolution of Interface
    Exceptions,Exception Handling in Object Oriented
    Systems Workshop at ECOOP'2000, June 12, 2000.
  • Waldo, J. "Throwing Things," UNIX Review's
    Performance Computing, vol. 16, p71, May 1998.

23
Optimization of Exception Handling
  • Thank You
  • Kris Hjelmeland
Write a Comment
User Comments (0)
About PowerShow.com