Virtual Machinery logo
Sidebar 4 - MI and MINC - Maintainability Index
Sidebars Home Products Downloads About us Contact us Links
**** Just released - JHawk 6.1.3 - See here for details - new Review Factor metric and DataViewer command line service to create motion charts (Professional licenses only) ****

Click here to download demo Click here to see details of our JHawk Java Metrics product

MI and MINC - Maintainability Index

The maintainability index (MI) is a compound metric designed at the University of Idaho in 1991 by Oman and Hagemeister. The primary aim of the metric is to determine how easy it will be to maintain a particular body of code. It's great claim to fame is that it was validated in the field by Hewlett Packard in a fairly extensive trial (outlined below). The Maintainability index was originally defined as -

       MI = 171 - 3.42ln(aveE) - 0.23aveV(g') - 16.2ln(aveLOC)

Where aveE is the average Halstead Effort per module, aveV(g') is the average extended cyclomatic complexity per module and aveLOC is the average numbers of lines of code per module. Although the original formula was designed for use with procedural languages - Java developers can think of a module as either a package, a class or a method or an overall system comprising of a number of these elements. In general we probably want to look at this metric at a higher level then drill down to find out which parts of the system are contributing most to its low maintainability. It does not really make sense to calculate the maintainability index at the method level as it is far too granular to be of any real use. JHawk reflects this approach by providing calculations of MI at Class, Package and overall system level.

So this combines one of the Halstead metrics, McCabes Cyclomatic Complexity and that old favourite - Lines of code - you can find out more about these metrics in our other 'sidebars' discussions. The first modification to the metric related to comment lines, amending the formula to appear as follows -

       MI = 171 - 3.42ln(aveE) - 0.23aveV(g') - 16.2ln(aveLOC) + 0.99aveCM

where aveCM is the average number of comment lines per module. The idea here is that comment lines will increase the maintainability of the code.

A further modification is to use the average Halstead Volume instead of the average Halstead effort and vary the constant slightly resulting in the following basic formula -

       MI = 171 - 5.2ln(aveV) - 0.23aveV(g') - 16.2ln(aveLOC)

Again this version can be modified by including the comment lines. In a further revision of the metric the comment part was modified to use the following calculation -

      50 * sin(sqrt(2.46*aveCM)

This formula is believed to give a better measure of the contribution of comment lines to maintainability. However as it is a sin function there are a number of situations where the addition of comment lines can actually cause a reduction in the maintainability figure. Ultimately though the actual contribution that comment lines make to maintainability is their usefuleness to the reader of the code rather than their quantity. Unfortunately we haven't yet managed to find a way of automatically assessing the quality of comments. For this reason many development shops using this metric leave off the comment part those who retain tend to use the modern version shown immediately above rather than the original measure.

Coleman and Ash (Hewlett Packard employees) used Omans initial maintainability index to compare two competing third party products which Hewlett Packard was contemplating purchasing. Both were written in C and were designed for the Unix platform. Both were roughly the same size - about a quarter of a million lines of code divided into ca 3000 modules. As well as carrying out the automated test with Omans formula they asked their own engineers to assess the maintainability of the two products by making a judgement on the maintainability of each file in the system. The eventual outcome showed the engineers verdict to be that one of the systems had low maintanability and that the other was highly maintainable. The corresponding values for MI were 89 (on the low maintainability system) and 123 on the highly maintanable system. While this was just a first study involving only two systems the sample was large enough to give HP the confidence to purchase the system with lower maintainability.

In the JHawk product we provide two versions of the Maintainability Index - MINC (MI with No Comment part) and MI (including the comment part). We use the original formula combined with the more modern comment part i.e.

      MI = 171 - 3.42ln(aveE) - 0.23aveV(g') - 16.2ln(aveLOC) + (50 * sin(sqrt(2.46*aveCM))

In the case of JHawk we use Java statements rather than lines of code for reasons that we explain more fully in sidebar 1.

References
  • Oman, P. W.; Hagemeister, J.; and Ash, D., A Definition and Taxonomy for Software Maintainability, Technical Report #91-08-TR, Software Engineering Test Laboratory, University of Idaho, Moscow, ID, 1991.
  • Coleman, D., Assessing Maintainability, Proceedings of the Software Engineering Productivity Conference 1992, Hewlett-Packard, Palo Alto, CA, 1992, pp. 525-532.
  • Coleman, D.; Ash, D.; Lowther, B.; and Oman, P. W., Using Metrics to Evaluate Software System Maintainability, IEEE Computer, 1994, 27(8), pp. 44-49.
  • If you want to find out more about Java metrics you can read our full tutorial here or you can read the individual sections on System and Package Level Metrics Class Level Metrics and Method Level Metrics.

     
     
     
    You may be interested in our products. All have demo or trial versions. Just click on the links below to find out more -
     
     
     
     
     

    All our products can be purchased online - just follow the link below -

     

     
     
     

    Contact Us

    © 2020 Virtual Machinery   All Rights Reserved.