From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,92c39a3be0a7f17d X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-03-16 02:37:17 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: kcline@optelnow.net (Kevin Cline) Newsgroups: comp.lang.ada Subject: Re: code partitioning (was: Future with Ada) Date: 16 Mar 2002 02:37:17 -0800 Organization: http://groups.google.com/ Message-ID: References: <9F6CC4A4404878F6.5B5BBAA9D5258CDF.AA7E4D06ED4F8781@lp.airnews.net> <4519e058.0203150615.4282773b@posting.google.com> NNTP-Posting-Host: 24.219.81.150 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1016275037 16547 127.0.0.1 (16 Mar 2002 10:37:17 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 16 Mar 2002 10:37:17 GMT Xref: archiver1.google.com comp.lang.ada:21328 Date: 2002-03-16T10:37:17+00:00 List-Id: dennison@telepath.com (Ted Dennison) wrote in message news:<4519e058.0203150615.4282773b@posting.google.com>... > "John R. Strohm" wrote in message news:<9F6CC4A4404878F6.5B5BBAA9D5258CDF.AA7E4D06ED4F8781@lp.airnews.net>... > > In practice, in thirty years of slinging bits, both as student and as > > professional, I have seen exactly one procedure that NEEDED to be more than > > one printer page of code and that COULDN'T easily be factored down any > > further. (For the record, it was the photon torpedo routine in the old > > Matuszek-Reynolds-McGehearty-Cohen STARTRK game.) > > I once had a command decoding and dispatching routine that had a >50 > branch case statement. Not only was it really big, but it completly > blew by our MacCabe complexity target (somewhere around 4 or 5 I > belive). There was no cleaning that baby up. I have done this a few times in different ways: * Use yacc or a similar tool to generate the code. I did this when I wrote an Ada program to parse Ada-83 package specifications. * Convert the code to data. During initialization, create a tree with nodes labeled by commands and subcommands, with functions at the leaves. * Embed the Tcl interpreter into the application. This gives the users a lot scripting functionality for free.