0

Looking for some metrics which can be used to determine cost of given code (maybe versus cost of "fixed" code).

I've already found some generic ideas like (bugs/cost per line of code), but I'd like to know more about how you can determine the maintenance/feature development cost of a code base.

4

You can't

Not directly, because each feature is different, each application is different, and each developer is different.

That said, there are some indirect measures you can use to approximate the information you are looking for:

Cyclomatic complexity - in its simplest form, a measure of how many different ways through a given function there are. As a general rule, a high level of cyclomatic complexity means your function might be doing too much and could stand to be broken down more.

Module/function length - is a crude measurement (similar to lines of code but taken at the unit level rather than an overall level) but in general terms, the largest functions are also likely to be the most complex and the most troublesome.

Depth of inheritance - roughly speaking how many objects up and down the chain the current object links to. A customer object might be a specialized type of person object and have 3 address objects (residence, billing, shipping), multiple order objects which in turn have order line objects which then have product objects... You get the point. The more dependencies on an object, the more complex the code, and the more likely the code is to have some kind of problem.

This is not an exclusive list by any means. There is a decent summary available at this site (I have no affiliation) although it doesn't mention the one metric that should be used everywhere - WTF Per Minute. At the risk of sounding flippant, if the reaction in a code review or from a tester is "WTF???", the code has a problem. If a test session or a code review has generates a lot of "WTF???" reactions, that code has a lot of problems and needs attention.

And of course, the ultimate metric is pretty much impossible to measure directly, namely the proportion of customers and potential customers who walk (that is, abandon the software or go elsewhere) because the software exceeds their personal WTF limit. You really can't measure how many people look at your site and consider possibly using your software then decide they don't have enough confidence in your company's ability to deliver because of what they see on the website.

| improve this answer | |
  • 1
    Additionally, looking from another perspective, you can only measure what you know. The cost of something, strictly speaking, can only be know a posteriori and partially. Any metric will show only what it measure - not the "true" cost of it. – João Farias Feb 20 '19 at 8:50
  • Thank you very much, this was the answer I was looking for (regardless it's about "I can't"). While I hoped for more answers, yours is truly capturing the essence of it (and why it's impossible to do it). – fabrik Mar 4 '19 at 10:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.