差異處

這裏顯示兩個版本的差異處。

連向這個比對檢視

java:effective_java:exceptions:checked_vs_unchecked [2022/04/11 23:34]
tony 建立
java:effective_java:exceptions:checked_vs_unchecked [2023/06/25 09:48]
行 1: 行 1:
-{{tag>​java effective_java exceptions}} 
-====== Effective Java - Use checked exceptions for recoverable conditions and runtime exceptions for programming errors (ToDo) ====== 
-===== Introduction ===== 
-這個Item在強調例外的使用時機,包含 
-  * Checked Exceptions應用在recoverable conditions 
-  * Unchecked(Runtime) Exception應用在programming errors 
-下一個問題就是怎麼定義recoverable conditions與programming errors。我分享[[https://​www.books.com.tw/​products/​0010637503|笑談軟體工程:例外處理設計的逆襲]]中的觀點,與我的看法給大家參考。 
-  * Programming errors: 
-  * Recoverable conditions: 
  
-除此之外,這個Item還有提到幾個設計要注意的事情:​ 
-  * 按照慣例,Error應保留給JVM使用,用以表明程序無法繼續執行的情況。所以開發人員通常不該去Extend Error。 
-  * 例外本身是有著設計上的代表意義,可以在類別上定義能供給Client做進一步處理的介面。不建議Client使用例外本身的字串訊息去做例外處理,因為字串訊息說變就變,程式容易出問題。 
-===== Note ===== 
-Effective Java第三版Item 70。 
-===== Reference ===== 
-  * Effective Java, 3/e 
-  * [[http://​teddy-chen-tw.blogspot.com/​2011/​05/​checked-or-unchecked-exceptions-1.html|搞笑談軟工 - Checked or unchecked exceptions (1)]] 
- 
-=====    ===== 
----- 
-\\ 
-~~DISQUS~~