Domanda

I want to know that what should be the standard range of cyclomatic complexity?

And does it depends on language or platform or it is common for all?

I am using State of Flow - EclipseMetrics which is a Eclipse plugin calculates various metrics for your code during build cycles and warns you, via the Problems view, of ‘range violations’ for each metric.

È stato utile?

Soluzione 2

I have refered this link - http://www.javaworld.com/community/node/1005

Cyclocmatic complexity = Number of decision points + 1

The decision points may be your conditional statements like if, if … else, switch , for loop, while loop etc.

The following chart describes the type of the application.

Cyclomatic Complexity lies 1 – 10  To be considered Normal applicatinon

Cyclomatic Complexity lies 11 – 20Moderate application

Cyclomatic Complexity lies 21 – 50Risky application

Cyclomatic Complexity lies more than 50Unstable application

Altri suggerimenti

As low as possible, just like any other code. Generally it's recommended to keep the cyclomatic complexity below 5.

In reality, that's easier said than done though. Good luck!

This question is independent of your environment. It does not matter if you develop for android or for Java EE.

The cyclomatoc complexity only helps you to keep your code maintainable. The computer has no problem with a high complexity but you will not understand your code if the complexity is too high.

As Joris mentioned a value of 5 is fine as a limit but in reality it is sometimes hard to achieve.

the cyclomatic compexity is not dependent on platform or language. (see definition of cyclomatic complexity)

It is also dependent on the inherent complexity of the task you have to solve. your code's complexity cannot be lower than that of the task, otherwise the code is simplified and is missing something.

Often you can reduce the cyclmatic complexity of a apecific method by refactoring.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top