Exception Handling
1
Institute puter Software
Nanjing University
Outline
Introduction
Java Exceptions
Manchester University, Kung-Kiu Lau, CS3101
/~kung-kiu/cs3101/
Java Exception机制的不当使用示例
C++ Exceptions
/~ingber/SNL/CS162/PowerPoint/
Eiffel Exception Handling
Summary
2
Institute puter Software
Nanjing University
简介
问题
何谓“异常(Exception)”?
一种情况要异常到什么程度才算“异常”?
为什么要引入异常处理机制?
Robustness readability?
如何进行异常处理?
Mandatory or Optional
不同的认识,不同的答案
Java/C++/C#
Eiffel
3
Institute puter Software
Nanjing University
Java Exception Mechanisms
Java 对 Exception 的界定较宽
因而需认真区分不同类型的 Exceptions
Java的Exception机制回顾
try/catch/finally
自定义Exceptions
Java Exception与Design by Contract
Exception的转换
4
Institute puter Software
Nanjing University
Understanding Java Exceptions
这部分使用Manchester University, Kung-Kiu Lau, CS3101 的PPT Slides
/~kung-kiu/cs3101/
5
Institute puter Software
Nanjing University
What are Exceptions?
Many “exceptional” things can happen during the running of a program, .:
Bug in the actual language implementation
User mis-types input
Web page not available
File not found
Divide by zero
Array index out of bounds
Method called on a null object
Out of memory
Exceptions are unexpected conditions in programs.
checked
unchecked
sys errors
6
We can distinguish 3 categories:
checked exceptions — Problems to do with the program's in
学习党章笔记 来自淘豆网www.taodocs.com转载请标明出处.