1

I'm reading Kent Beck's “TDD by Example” and I can't understand why the cyclomatic complexity of his program is fractional.

Table from the book

In Wikipedia the complexity is defined as M = E − N + 2P where E, N and P are integers.

Dave Schweisguth
  • 36,475
  • 10
  • 98
  • 121
Igor Adamenko
  • 861
  • 1
  • 8
  • 20
  • 1
    There are four definitions of CC. :-) Take a look here if you need example with drawings and calculations: http://stackoverflow.com/questions/12599942/cyclomatic-complexity-of-ifab-and-cd-and-ifab-or-cd/21658235#21658235 – LAFK 4Monica_banAI_modStrike Apr 11 '16 at 19:19

1 Answers1

2

I believe that's the average of each method's standalone cyclomatic complexity (M = E - N + 2). I'm not going to calculate it myself, but

  • most of the methods shown have no conditionals by that point in the exercise (Kent eliminates them when he can), so their cyclomatic complexity is 1
  • Bank.rate does have a single if (page 63)

so it seems reasonable that the average is just above 1.

Dave Schweisguth
  • 36,475
  • 10
  • 98
  • 121