Determining C Complexity
Jim Miller
jamiller at hpcupt1.HP.COM
Wed Jul 25 02:51:36 AEST 1990
>A good policy (by my experience) is to take complexity metrics (and the like)
>with a grain of salt: your metric rates some piece of code with a
>McCabe complexity of 22, and the average is 8.2. So you check the code;
>
>--
>John T. Baldwin | Disclaimer:
>search technology, inc. | Some people claim I never existed.
>Norcross, Georgia | (real .sig under construction
>johnb at srchtec.uucp | at Starfleet Orbital Navy Yards ;-)
>----------
For example, I understand that a huge case statement, where each case of
100's may only be 2-6 lines long (can you say "apply production" :-),
will give an enormous McCabe complexity.
It is obviously better coding style for the apply production routine
to break the range up into subranges, and call routines like
apply1to20(), apply21to40(), ..., apply201to220, ...
Much easier to maintain and read :-)
Obviously.
jim miller
Standard disclaimer
More information about the Comp.lang.c
mailing list