Thursday, September 13, 2007

Cyclomatic Complexity

Assalamualaikum and good evening....

Today, we learnt something new in class...Cyclomatic Complexity (CC)...

Cyclomatic complexity may be considered a broad measure of soundness and confidence for a program. Introduced by Thomas McCabe in 1976, it measures the number of linearly-independent paths through a program module. This measure provides a single ordinal number that can be compared to the complexity of other programs.
(http://www.sei.cmu.edu/str/descriptions/cyclomatic_body.html)


The cyclomatic complexity of a software module is calculated from a connected graph of the module.

According to Puan Badariah, there are few formulas to calculate the CC...

Formulas:
  • CC = E - N + 2 or
  • CC = E - N + p

where:

E = number of edges

N = number of nodes

p = number of connected components

Puan Badariah also gave us an exercise on CC... We will discuss about it next week...

Girls...as a reminder, this is the codes of the exercise that we are required to do...

if x = 1 {
print "1";
else
print "2";
}
if y = 1 {
print "A";
else
print "B";
}

  • For the exercise, firstly, we need to draw the equivalent graph (path).
  • Secondly, we need to give reasons on the implication of testing (Cyclomatic Complexity)

Okay...that's all...:)

Selamat Berpuasa to all...

No comments: