MI AND CMI

上一篇 / 下一篇  2014-12-22 14:21:13

MI standard for Maintainability Index, which is a number reported by Glority MI tools.
Generally saying, we treat code is easier to maintain if:

  1. Each method has fewer lines of code.
  2. Each method has simpiler logic.
  3. Each method has good document and inline comments.
MI With Comment = 171 - 5.2ln(aveV) - 0.23aveV(g') - 16.2ln(aveLOC) + (50 * sin(sqrt(2.46*aveCM))
MI Withut Comment = 171 - 5.2ln(aveV) - 0.23aveV(g') - 16.2ln(aveLOC)

ave

You can see all above factors are ave(average based). ave here means average per methods. Generally saying, smaller method/functions will have better MI.

aveV

aveV isHalstead volumes. this is a metric to measure how many info the code contains. It's a number base the number of operators and operands in the code.

The lower aveV, the easier to maintain the code since it contains less info.

aveV(g')

aveV(g') is averageCyclomatic Complexity. This is a metric to measure how complex the code is logically. it will count brances in the code(if/else, while, for, swith/case).

The lower aveV(g'), the easier to maintain the code

aveLOC

aveLOC is Lines Of Code. Less lines is better

aveCM

aveCM = Lines Of Comments / (Lines of Comments + Lines of Source Code), so this is a number in0, 1.
More comments is easier to maintian, but the impoertance of the comments comes lower when the comments rate more than 0.3.


TAG:

 

评分:0

我来说两句

日历

« 2024-05-05  
   1234
567891011
12131415161718
19202122232425
262728293031 

数据统计

  • 访问量: 47736
  • 日志数: 36
  • 建立时间: 2013-06-05
  • 更新时间: 2014-12-22

RSS订阅

Open Toolbar