[comp.software-eng] Determining C Complexity

tomr@ashtate (Tom Rombouts) (07/20/90)

In article <3205@mica6.UUCP> motcid!henley@uunet.uu.net writes:
>I'm looking for the different points of view related to determining
>the complexity of a C program.  If anyone knows of any programs available
>that already do this I'd like to have some pointers to those as well.  The
>tool or theories would be applied to source code to enable management the
>ability to maintain stats regarding such things as:

In the DOS world, PC Metric for about $200 is a pretty good little
tool for this.  The manual also includes some history of the various
complexity algorithms it can use.  I see that versions for FORTRAN,
Pascal and Modula-2 are also available.  

However, be warned that (in my experience, at least), trying to quantify
software development into precise statistics based on things such as
lines of code, percentage of project completed, etc. is difficult at
best.  You can make sophisticated charts and graphs that will impress
managers or investors, but there is no real way to measure such things
as intelligence of the overall design and architecture, elegance of
algorithms, or quality of comments and documentation.  

Tom Rombouts  Torrance Techie  tomr@ashtate.A-T.com  V: (213) 538-7108

DISCLAIMER:  The above opinions are my own and do not necessarily rep-
resent the views or opinions of any known corporate entity.

warren@eecs.cs.pdx.edu (Warren Harrison) (07/21/90)

In article <1050@ashton.UUCP> tomr@ashton.UUCP (Tom Rombouts) writes:
>In article <3205@mica6.UUCP> motcid!henley@uunet.uu.net writes:
>>If anyone knows of any programs available
>>that already do this I'd like to have some pointers to those as well. 
>
>In the DOS world, PC Metric for about $200 is a pretty good little
>tool for this.  The manual also includes some history of the various
>complexity algorithms it can use.  I see that versions for FORTRAN,
>Pascal and Modula-2 are also available.  
>
There are versions of PC-METRIC for UNIX, VMS and Apple Macintosh too.
The languages supported are Ada, C, COBOL, Pascal, FORTRAN, dBASE, Modula-2,
QuickBASIC and a variety of assembly languages (all languages are not
supported on all machines). The UNIX versions are $495, but the PC and Mac
versions are still $199.

Disclaimer: My wife owns the company that makes and sells PC-METRIC ...

Warren


==========================================================================
Warren Harrison                                          warren@cs.pdx.edu
Department of Computer Science                                503/725-3108
Portland State University   

johnb@srchtec.UUCP (John Baldwin) (07/24/90)

In article <1050@ashton.UUCP> tomr@ashton.UUCP (Tom Rombouts) writes:
>
>.......................... there is no real way to measure such things
>as intelligence of the overall design and architecture, elegance of
>algorithms, or quality of comments and documentation.  

True.  But you CAN quantify (statistically, not deterministically) such
things as "did the programmer, in general, decompose the design into
subroutines (functions, procedures, ad infinitum) of manageable size?"

Naturally, you shouldn't become the "code police" on the basis of those
quantifiers alone.  For instance, a certain routine may have to run on
a special stack of limited size; therefore it might be coded as an extremely
long procedure, with calls only to "primitive" subroutines, in order to
avoid exceeding stack depth.

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;
there's no immediate reason for the excess complexity (based on your perusal).
You talk to Joe Programmer, who provides an extremely logical explanation
AND a reasonable defense for doing things this way (as opposed to....).
BTW, note that both an explanation AND a defense are required.

Having satisfied all of this, you good-naturedly remind Joe P. that he
should place a comment near the beginning of the source code which contains
a synopsis of his explanation and defense of the design.  In parallel, you
jot "ok" next to this metric, with some kind of cross reference.

-- 
John T. Baldwin            | Disclaimer:
search technology, inc.    |    Some people claim I never existed.
Norcross, Georgia          | (real .sig under construction
johnb@srchtec.uucp         |  at Starfleet Orbital Navy Yards ;-)