在現有的研究文獻中,有人提出以軟體重構的方式,來移除例外處理程式中常出現的「壞味道」。雖然現有的幾個例外處理工具如RLMET和ENHANCE,可以協助開發人員以視覺化的方式來分析例外發生點及影響範圍。但在實際開發軟體的情況而言,這些工具只能做到分析層面的事情,對於開發或維護人員在修改例外處理程式時這方面,並無太大實質上的幫助。 在本論文中,提出偵測例外處理壞味道的方法,及例外處理重構方式的套用設計。我們在Eclipse平台上開發一個例外處理工具,來自動化偵測專案中存在哪些會危害系統強健度的壞味道。開發人員還可透過工具自動化重構程式碼來移除壞味道,進而降低手動修改程式的時間,快速達到提升系統強健度的目的。最後會透過一個現有的舊系統為案例,來說明如何透過工具來逐步提升系統的強健度等級。
Bad smells in exception handling code can be eliminated with refactoring. Although a number of tools have been developed to provide visualization support for analyzing exception handling constructs to identify bad smells in exception handling code, applying these tools in real cases remains difficult because these tools focus on the analysis of exception handling construct, not modifying exception handling code. In this thesis, we propose an approach to detect bad smells in exception handling code in Java and develop a tool that supports automatic detection in Eclipse platform. The tool also provide code templates for disciplined exception handling that can be readily plug-in and modified to suit the program’s need. We present a case study on applying the tool to improve the exception handling of an existing application program step by step.