« Unbelievable. | Main | On MacOS 10.4 and Sherlocking... »

Cyclomatic Complexity

Code Improvement Through Cyclomatic Complexity (via DevelopingStorm).

Interesting read. A couple of comments of yours truly:

  • I don't think there's a need for metrics here. Applying common sense is sufficient. Do you have to scroll to read the whole message?. It's pretty likely that the method is too complex. More than 2 or three if..then..elses? It's pretty likely that the method is too complex.
  • As the example on page 2 shows, you'll need to use good judgement when getting rid of cyclomatic complexity. Getting rid of intra-method complexity may introduce complexity on an architectural level. Although I prefer architectural complexity (or, for the lack of a better word - elaborate architecture) over cyclomatic complexity, I don't think getting rid of two if..then..elses justifies a substantial architectural change. If you re-visit those if..then..elses later on and you feel the need to add a few more if..then..else in the same method, go for the architectural change. But go for it when there's an actual need and not for the sake of architectural beauty.

About

This page contains a single entry from the blog posted on June 28, 2004 3:16 PM.

The previous post in this blog was Unbelievable..

The next post in this blog is On MacOS 10.4 and Sherlocking....

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type 3.33