1. Use exception only for exceptional conditions
- Good API design 要提供讓client檢查狀態的API
2. checked exception and runtime exception
3. 盡量避免不必要的checked exception
- Client方便
- 可將checked轉成 unchecked
4. Favor use standard exception
- IllegalArgumentException
- IllegalStateException
- NullPointerException
- IndexOutOfBoundException
- ConcurrentModificationException
- UnsupportedOperationException
5. Throw exceptions appropriate to the abstraction
- exception translation
- exception channing
6. Document all excepion
7. Include failure-capture information in detail message
- 包裝有用的資訊
- 需要自己改寫Exception
8. 維持Exception的原子性
- Object immutable
- rollback
- check first
9. Don't ignore it
About Me
星期五, 8月 01, 2008
Effective Java Chapter 9 Exception
訂閱:
張貼留言 (Atom)


0 意見:
張貼留言