McCabe complexity
- From: "Kenneth Eaton" <Kenneth.dot.Eaton@xxxxxxxxxxxxx>
- Date: Fri, 30 May 2008 21:32:01 +0000 (UTC)
I was just running mlint with the '-cyc' option to look at
the cyclomatic complexity of my code. I tend to break
things up fairly well into smaller subfunctions, and most
of them give me values in the range of 1-10. However, I
noticed that the subfunctions which routinely gave me
values of 25-40 are those with big switch statements,
either containing a few cases with a lot of code, or a lot
of one-line cases.
It seems clear that the McCabe complexity measure doesn't
like switches all that much, unless they're tiny and
simple. Is this anything other people have seen? Should I
be concerned about this? In other words, are there
better/more efficient ways I should be doing things that
don't involve switches? (Although I'm not sure how I would
do away with them).
Or maybe this is just one of many subjective complexity
measures that I just shouldn't worry about? What are
everyone's thoughts?
Ken
.
- Follow-Ups:
- Re: McCabe complexity
- From: Walter Roberson
- Re: McCabe complexity
- Prev by Date: Re: Passing a MATLAB user defined class object to a MEX function
- Next by Date: using surf
- Previous by thread: Matrix of subclasses with same base class, how? Concatenate fails
- Next by thread: Re: McCabe complexity
- Index(es):
Relevant Pages
|