Why Should You Calculate an RPG Program’s Complexity?
As described in my previous post, Codelyzer now has the ability to calculate several code metrics for RPG programs, probably most usefully, a maintainability index (MI).
This algorithm was developed a couple decades ago and was used extensively by HP internally. It has also been used by many others over the years and has been refined based on common experience. While the algorithm is claimed to be language independent, I do not know of anyone who has used it for RPG. Based on my initial observations I think it may need some adjustments for RPG, but I think it is well worth using as a starting point.
Why have companies used these kinds of metrics over the years in large, complex systems? There a number of possible uses, but first it needs to be stated that it takes time to work with these numbers and develop an ability to interpret them for your organization. Some of the uses of complexity metrics are to aid the following processes:
Estimating – various studies have correlated poor maintainability scores with higher defect rates. These ratios can be incorporated into the estimating process to help make estimates more accurate.
Designing modifications – subroutines and procedures with a low MI are basically to be avoided whenever possible. When designing modifications knowledge of where the most unstable code is located can be factored into design decisions.
Coding – when subroutines or procedures with a poor MI are modified it may be sensible to institute a practice of required peer reviews or walkthroughs for that code.
Testing – when subroutines or procedures with a poor MI are modified it may also be sensible to plan for additional testing of that code.
Managing maintainability – one of the goals of software maintenance should be that maintenance work does not result in lessening the maintainability of the system. Establishing a procedure of comparing before and after MI measurements helps to keep the application’s maintainability from degrading, thus prolonging the application’s life and preserving its value.
Additionally, some organizations have established a practice of re-engineering code that becomes insufficiently maintainable as a means of preserving the value of the software investment.
Migrating – when migrating code to another language or platform, it may be sensible to consider re-engineering those sections of code with poor MI scores.