- Code Coverage– describes the degree to which the source code of a program has been (unit) tested. Popular tools to measure code coverage in Java is Emma. You can find more code coverage tools list here
- Code Complexity - is another measure that can used to identify and quantify the code maintainability. Factors like Cylometric Complexity, Halstead's software science metrics and Lines of code metrics are some of the factors. Infact, there is a measure called Maintainability Index that can be calculated by using the factors. Check out tools to calculate MI here.
- Documentation - is another factor that be used to quantify code maintainability. Documentation can be your normal JavaDocs or the inline source code commenting. You have tools like JavaNCSS where NCSS ( non commeting source statements) that can be applied at class, method/function level
- Code Format - is not really a measure but is an indicator of the readibility of the code.Tools like CheckStyle can help identify the code formatiing problems (from non standard class headers, identation issues to spacing, variable naming convention and so on). Any issues reported by the tool can be used an indicator of the maintainability of the code
Code should be maintainable
How many times I have heard the statement “Code should be maintainable” from clients, Delivery Managers or Project Managers. I always ask them, how you quantify maintainability. I am listing down some of the factors that can be measured and help make the code maintainability quantifiable.