軟體缺陷指標

軟體缺陷指標(Software Defect Indicator)是源代码中會出現的一些模式,和程序错误有強烈的相關性,程序错误是指程式碼中有錯誤或是遺漏程式,會因此造成程式的動作異常。在檢視计算机程序時,不一定每次都可以直接識別到程式的錯誤,但因為軟體缺陷指標有固定的型式(有時也稱為反面模式代碼異味),表示程式有可能有問題。

以下是一些軟體缺陷指標的例子:

  • 無效不會執行的程式:已撰寫好的程式碼,而程式設計者刻意關閉程式不執行,也沒有相關註解說明此程式為何要關閉,或是這程式何時會恢復執行的資訊。
  • 函式太過複雜:程式(方法、模組、副程式、函式、子函式、程序,或是任何有名稱的一塊程式碼)中包括了十個條件敘述中的邏輯判斷式[1]
  • 沒用到的變數:沒有參考到的變數意味著可能有其他的錯誤[2]

相關條目

參考資料

  1. William T. Ward: "Software Defect Prevention Using McCabe's Complexity Metric", Hewlett-Packard Journal, April 1989, pp 64-69: Control-flow complexity has been correlated with low reliability and frequent errors.
  2. David N. Card, Victor E. Church, and William W. Agresti: "An Empirical Study of Software Design Practices", IEEE Transactions on Software Engineering, SE-12, no. 2, February 1986, pp 264-71: 46 percent of routines with no unused variables had no errors compared to only 17 to 29 percent for those with one or more unreferenced variables.

外部連結

This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.