Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

In general, maintainability index relies on many factors. For example, in Visual Studio, it rely on cyclomatic complexity, depth of inheritance, class coupling and lines of code; those four values must be as low as possible.

At the same time, I've never seen, neither in code metrics tools, nor in books, the comparison between only cyclomatic complexity (CC) and lines of code (LC).

Does it make sense to compute such ratio? What information does it give about the code? In other words, is it better to decrease more the CC than the LC to have a lower ratio?

What I notice is that for small projects, the ratio CC/LC is low (⅓ and lower). In other words, LC is high, and CC is low. In large projects, CC/LC is in most cases bigger than ½. Why?

share|improve this question
9  
The only valid code quality metric is WTFs/minute ;) –  delnan Mar 8 '11 at 19:27
1  
Your last prediction (small x large projects) probably depends on the platform and the amount of boilerplate code one must write to get a minimal project running. Using the raw Win32 API the amount of boilerplate to real code is high for small projects, for example. This inflates the number of line of code. You could select a few random open source projects and do a scatter plot of CC x LC. Maybe you can find something useful out of it. –  Vitor Mar 8 '11 at 20:33
    
The ratio you are suggesting is interesting IMO but I want to suggest to replace lines of code (LOC) with Function Points (FP) or Use Case points (UCP) and see what you get. –  M.Sameer Mar 19 '11 at 18:15

3 Answers 3

up vote 5 down vote accepted

From http://en.wikipedia.org/wiki/Cyclomatic_complexity

Les Hatton claimed recently (Keynote at TAIC-PART 2008, Windsor, UK, Sept 2008) that McCabe Cyclomatic Complexity has the same prediction ability as lines of code.[11]

The ratio has about the same prediction ability as either used separately.

share|improve this answer

There is a metric of cyclomatic complexity per source statements - it's called cyclomatic complexity density. This metric can be used to estimate the maintenance time and effort required for software projects.

share|improve this answer

Sorry but I disagree with this statement:

The ratio has about the same prediction ability as either used separately.

A ratio is clearly not the same as an individual metric. Based on empirical data, Hatton claims that CC is proportional to XLOC with a constant ratio of about 0.25 (see slide 17) for his specific data set. Hence whether your XLOC is 60 or 400, your CC:XLOC ratio will be about 0.25 (ignoring statistical deviations at higher numbers). So the ratio is not predictive whatsoever.

share|improve this answer
    
surely you are more likely to get statistic deviation with small numbers –  jk. Sep 15 '11 at 8:11

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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