Sunday, September 27, 2009

Code Metrics - Maintainability Index

  • This is an index from 0 to 100 indicating the overall maintainability of the member or type or program
  • This index is based on the following metrics,
    •  Halstead Volume (which factors in the number and use of operands and operators),
    • Cyclomatic Complexity
    • Lines of Code
Maintainability Index = 171 - 5.2 * log2 (Halstead Volume) - 0.23 * (Cyclomatic Complexity) - 16.2 * log2 (Lines of Code)

  • A low number indicates code that is complex and hard to maintain
 VSTS2008 has the inbuilt maintainability measuring technique.


Maintainability Definition:

Range
Level
20-100 inclusive
  High Maintainability
10-19 inclusive
  Moderate Maintainability
0-9 inclusive
  Low Maintainability
 

1 comment:

  1. you know this is a tough game to crack.

    I find that try {} catch{} lowers the index by 5 to 10.

    linq is even worse.


    what's your strategy of lowering this value other than limiting nested loops or ect,....

    ReplyDelete