Xref: utzoo comp.lang.c:30485 comp.software-eng:3964 Path: utzoo!attcan!uunet!cs.utexas.edu!swrinde!emory!stiatl!srchtec!johnb From: johnb@srchtec.UUCP (John Baldwin) Newsgroups: comp.lang.c,comp.software-eng Subject: Re: Determining C Complexity Keywords: C, complexity, metrics, cyclomatic complexity, McCabe Message-ID: <142@srchtec.UUCP> Date: 23 Jul 90 21:25:23 GMT References: <3205@mica6.UUCP> <1050@ashton.UUCP> Followup-To: comp.lang.c Organization: search technology, inc. Lines: 34 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 ;-)