Presentation is loading. Please wait.

Presentation is loading. Please wait.

1. Cyclomatic complexity

Similar presentations


Presentation on theme: "1. Cyclomatic complexity"— Presentation transcript:

1 1. Cyclomatic complexity
Introduced by Thomas McCabe in 1976, it measures the number of linearly-independent paths through a program. Cyclomatic complexity is a measure of source code complexity. When computing the Cyclomatic Complexity, the result is returned as a number. The bigger the number, the more complex the program is.

2 Complexity  V(G) = edges – nodes + 2
The metric tries to capture the number of paths through the code. The complexity typically increases because of branch points. To compute the Cyclomatic complexity: Complexity  V(G) = edges – nodes + 2 Example:

3 Complexity  V(G) = edges – nodes + 2
If(success) Do something; Else Do the other thing; V(G) = 4 –4+2 = 2

4 2. Comments percentage % The goal is to maximize code understandability. The more you provide documentation, the more people understand it. Comments% = comment lines / total number of lines.

5 3. Size (Number of Lines) The size can be found by counting the non-empty lines. Comment Lines, and Java_doc Lines are counted too. 4. Weighted Methods The methods in a class are counted. The more there are methods, the class becomes more complex

6 For each method, the number of lines is counted.


Download ppt "1. Cyclomatic complexity"

Similar presentations


Ads by Google