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=0.1 required=5.0 tests=BAYES_05,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,86fd56abf3579c34 X-Google-Attributes: gid103376,public From: wjwinn@kocrsv01.delcoelect.com (Bill Winn) Subject: Re: State machines and Goto's (was Re: Should internet support software be written in Ada?) Date: 1995/04/20 Message-ID: <3n5u2m$72f@kocrsv08.delcoelect.com>#1/1 X-Deja-AN: 101283296 distribution: usa references: <3kaksj$iur@isnews.calpoly.edu> <3ki9t8$c8l@Starbase.NeoSoft.COM> <3m3j73$php@tali.hsc.colorado.edu> <1995Apr7.141054.17419@sei.cmu.edu> <9511002.21479@mulga.cs.mu.OZ.AU> organization: Analysts International Corporation mime-version: 1.0 newsgroups: comp.lang.ada Date: 1995-04-20T00:00:00+00:00 List-Id: In article , fjm@ti.com communicates... >And what if the common code is (relatively) large and using a (relatively) >large number of the variables used by the procedure that it is already in and >needs them to have the values which they have at the point where the >'repeated' code occurs? Presumably you propose writing a function or >procedure with 15-20 parameters? I don't consider that particularly good >practice. > > If you need to send 15-20 parameters to a function I would say that your function is probably not sufficiently narrow in scope. According to most good software engineering principles that I have seen, a function should do *1* thing, do it well, and move on (thank you Charles Winchester III). Therefore, I would first look at the problem and see if the best abstraction has been choosen. A function with 15-20 paramters has probably not been properly abstracted. For the sake of argument let us assume that one has properly abstracted the problem and found that: (1) 15-20 data are needed for the function; and (2) it makes no sense to split the function into smaller functions (this is a stretch, but stick with me). In this case I would suggest that one could use accessor routines to the needed data, rather than passing all data as parameters. This would: (1) help support encapsulation of the required data elements; (2) avoid nasty interfaces; and (3) avoid global data (my CS degree requires me to say this!). Bill Winn Software Engineer - Analysts International Corporation ------------------------------- wjwinn@kocrsv01.delcoelect.com My views do not express the views of anyone except my alter-ego.