So the page on the website will have to wait until I rewrite my hand written notes before I transcribe them into HTML. I don`t think any of you were holding your breath waiting for cyclomatic complexity were you?
Tuesday, March 20, 2007
Today I was working on re-writing my notes on the testing question
that appear on the 2006 April exam. It involves definitions for
several types of testing as well as a discussion on cyclomatic
complexity. Since I had gotten the paper "A Complexity Measure by
Thomas J. McCabe 1976" I started to review it. I found some problems
with how I had learned cyclomatic complex and also discovered some
other new tidbits on the topic. One of the problems is that I was not
breaking the if statement in the code block into two ifs because of
the and. So I went to work on re-defining my diagram. I found that
in the paper it is stated that you should have unique entry and exit
nodes. They way they are drawn in the paper a diamond is used for a
branch point. I had not seen that in other places that I read about
cyclomatic complexity. It seems that the difficulty in getting the
paper makes others not want to read the original work. I am glad that
I did. It also could be that people are not using this metric much
because of the move to OO programming. Granted this stuff is still
pertinent to the body of a code block. Compilers under the covers
convert classes into subroutines of a sort. But generally this paper
talks in terms of stuff that is better left as history. One of the
sections is all about structured programming and how cyclomatic
complexity can show you if your program is structured or not. By old
definitions of structured programming OO programming is a completely
new paradigm. In the paper a quote was made of Donald Knuth about the
virtues of a GOTO. The author brings value to his method through
justification of a GOTO and using his method to determine when to use
it. So is cyclomatic complexity really adaptable today, probably in
some smaller capacity. Please don`t think that I am supporting the
virtues of a GOTO with that statement. Anyway, the examples are in
Fortran on a PDP-10. It was kind of coincidental that today I read on
slashdot that the "Father of Fortran had died at the age of 82".
Funny also in an unrelated story that Yes...A patent was granted in
2006 for the linked list. Our patent system sure is broken. Open
source all the way. Give it away and you won`t have to worry if
someone is stealing it. Also, you won`t be tempted to try a patent on
something just so you can litigate later. Back to cyclomatic
complexity. I learned also from the paper that there is a region
method. By counting the regions in a graph you can also get the same
result as using the Edges - Nodes + 2 method. This is reasonable. It
is a mathematical theorem..Euler maybe? It just brings a level of
estimation and validation so that I cannot mess it up on the test.
Having a quick estimation/confirmation is a good thing for me.