The first step in using exceptions in a particular development project , therefore , and much the most - neglected one , is to determine your program s requirements for exceptions 因此,在某個特定開發(fā)項目中,使用異常的第一步,也往往是最容易被忽視的一步,就是確定程序對異常的需求。
If the event is truly exceptional and is an error such as an unexpected end - of - file , using exception handling is better because less code is executed in the normal case 如果事件確實是異常的并且是一個錯誤(如意外的文件尾) ,則使用異常處理比較好,因為正常情況下執(zhí)行的代碼更少。
Consider using exception handling in any method that uses operators that may generate an exception , or that calls into or accesses other procedures that may generate an exception 如果任何方法使用可能生成異常的運算符,或者調用或訪問其他可能生成異常的過程,則在這些方法中應考慮使用異常處理。
Another variation on this lesson would be to log the original exceptions for an older framework like struts that didn t use exception chaining , so you can see the underlying causes of failures 本課程的另一個變體是記錄不使用異常鏈的舊框架(比如struts )的原始異常,這樣就可以查看失敗的底層原因。
That protection gives you the right ( subject to a narrow range of fair use exceptions ) to control how others copy the work , whether they copy it to republish it or to share an excerpt 此種保護給予你權利去控制別人如何拷貝你的作品(此權利受制于窄范圍的合理使用的例外規(guī)定) ,而無論他們拷貝是為了重新出版還是分享一個摘要。
Having used exceptions in c , where all exceptions are unchecked , i have found that one of the biggest risks of unchecked exceptions is that they are not self - documenting in the way checked exceptions are 通過在c + +中使用異常,其中所有的異常都是非檢查型的,我已經發(fā)現非檢查型異常的最大風險之一就是它并沒有按照檢查型異常采用的方式那樣自我文檔化。
It also consists of the bytecode for the program instructions the jvm interprets at runtime , jit code code that s already been compiled for the target processor , any native code , and some metadata that the jvm uses exception tables , line number tables and so on 它還包括程序的字節(jié)碼( jvm在運行時解釋執(zhí)行的指令) 、 jit代碼(已經為目標處理器編譯過的代碼) 、任何本機代碼和jvm使用的一些元數據(異常表、行號表等等) 。
My opinion is that , while properly using exceptions certainly has its challenges and that bad examples of exception usage abound , most of the people who agree with him are doing so for the wrong reason , in the same way that a politician who ran on a platform of universal subsidized access to chocolate would get a lot of votes from 10 - year - olds . rod johnson , author of j2ee design and development (我的觀點是,盡管恰當地使用異常確實是很難的,并且對異常用不好的例子大量存在,但是大多數贊同他的人是因為錯誤的原因才這樣做的,這與一個政客位于一個可以隨便獲取巧克力的平臺上參選將會獲得十歲孩子的大量選票的情況具有相似之處。