Thanks:  0
Likes:  0
Dislikes:  0

# Thread: What's the use of cyclometric complexity?

1. ## What\'s the use of cyclometric complexity?

Of course to calculate the complexity of the software.
But what's exact use in real time?
I mean how does that number(cyclometric complexity) will help improve my software?

Thanks

2. ## Re: What\'s the use of cyclometric complexity?

The cyclomatic complexity of a section of source code is the count of the number of linearly independent paths through the source code. For instance, if the source code contained no decision points such as IF statements or FOR loops, the complexity would be 1, since there is only a single path through the code. If the code had a single IF statement containing a single condition there would be two paths through the code, one path where the IF statement is evaluated as TRUE and one path where the IF statement is evaluated as FALSE.

Cyclomatic complexity is normally calculated by creating a graph of the source code with each line of source code being a node on the graph and arrows between the nodes showing the execution pathways. As some programming languages can be quite terse and compact, a source code statement when developing the graph may actually create several nodes in the graph (for instance, when using the "?:" ternary conditional operator in C, C++, C# and Java).

In general, in order to fully test a module all execution paths through the module should be exercised. This implies a module with a high complexity number requires more testing effort than a module with a lower value since the higher complexity number indicates more pathways through the code. This also implies that a module with higher complexity is more difficult for a programmer to understand since the programmer must understand the different pathways and the results of those pathways.

One would also expect that a module with higher complexity would tend to have lower cohesion (less than functional cohesion) than a module with lower complexity. The possible correlation between higher complexity measure with a lower level of cohesion is predicated on a module with more decision points generally implementing more than a single well defined function. However there are certain types of modules that one would expect to have a high complexity number, such as user interface (UI) modules containing source code for data validation and error recovery.

Thanks
Raj
Software Testing

3. ## Re: What\'s the use of cyclometric complexity?

[ QUOTE ]
The cyclomatic complexity ...
Thanks
Raj

[/ QUOTE ]

Or, if you would rather see the entire Wikipedia article that Raj copied and pasted without attribution, it's here:

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

4. ## Re: What\'s the use of cyclometric complexity?

It sounds like you have the definition already, so I won't go into that. Cyclomatic Complexity won't immediately help you in any way. It's a tool used more for estimation than anything else. It allows you to understand the complexity of an application as it might compare to others in your organization, or at least that's the way I make use of it.

So, let's say I just tell you I want you to tell me when a balloon will break. A logical first question, if we were meeting in person might be, "Where is this balloon?", "How big is the balloon?" Without some information about the balloon, you really can't estimate how much air it will hold. However, if you've tested balloons in the past and you can see how big the balloon is, you should be able to guess at about what point the balloon will break.

So Cyclomatic Complexity is like seeing the balloon. If you know the complexity of an application then you can, theoretically, compare it against other, similar projects and make a more educated guess, along with other historical data, as to how many bugs you might find, how long it might take to test, areas of concern, etc.

I have the luxury of working on a number of products, so there is a little deeper history, giving me a little more information, making my estimations a little more accurate. In the end, though, it's still just an estimation.

There may be other uses for this, but this is the way I use it in my job function.

5. ## Re: What\'s the use of cyclometric complexity?

Has anybody here calculated Cyclometric complexity(CC) of their project?
I mean I saw people calculating CC for simple 'For' loop and if else condition, But never heard somebody calculated CC for Giant commercial project.

Thanks

6. ## Re: What\'s the use of cyclometric complexity?

Nope, no real giants here. I'm wondering if there might be a calculator for it. I Googled and found a calculator for Delphi apps on the first page of results, but I wonder if there is one for other languages. That would make it easier.

7. ## Re: What\'s the use of cyclometric complexity?

Here's one commercial product that's available for a number of languages. A quick search also found this open source tool for C++.

I'd imagine that manually graphing the complexity of any object oriented language such as C++ with templates, virtual function calls, multiple inhertence, exceptions, operator overloading, pointers to objects, etc.. would be a nightmare. Particularly as many OO programs will be executing virtual methods extracted from arrays of pointers to objects.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.