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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,e55245590c829bef X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!p1g2000yqm.googlegroups.com!not-for-mail From: Shark8 Newsgroups: comp.lang.ada Subject: Re: Beginners question: Compound types, how-to? Date: Mon, 1 Nov 2010 12:59:27 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <86wroy58ff.fsf@gareth.avalon.lan> <86pqup5xfy.fsf@gareth.avalon.lan> <86y69d3rec.fsf@gareth.avalon.lan> NNTP-Posting-Host: 174.28.254.71 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1288641567 15400 127.0.0.1 (1 Nov 2010 19:59:27 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 1 Nov 2010 19:59:27 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: p1g2000yqm.googlegroups.com; posting-host=174.28.254.71; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12 ( .NET CLR 3.5.30729; .NET4.0E),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:15124 Date: 2010-11-01T12:59:27-07:00 List-Id: On Nov 1, 1:19=A0pm, Jeffrey Carter wrote: > On 11/01/2010 10:06 AM, Mart van de Wege wrote: > > > Shark8 =A0writes: > > >> You could have appended "_Type" to the type declaration giving > >> "Character_Type." > >> This gives the added advantage of allowing your parameters to be > >> highly descriptive, especially if you use named-association when > >> calling the parameters. > > > That's another way around it. Nice. Thanks. > > No, not nice. Terrible. > > "_Type" is just noise; you could use "_Global_Nuclear_Warfare" just as we= ll. You > should never be adding unnecessary noise to your code. I like the "_Type" more than the prefix of "The_" used in parameters within the Booch book on reusable Ada components (I don't like how the resultant calls look using named association). Push ( The_Stack =3D> This_Stack, Item =3D> Integer'(137) ); vs Push( Stack =3D> This_Stack, Item =3D> Integer'(137) ); I'll quite agree that it is [mostly] a matter of preference/taste, but to my thinking having the "_Type" appended for the type declaration is a little bit of redundancy {which is not always bad, else why do you carry a spare tire?}. Most of the places you'll use the "_Type" suffix would be in parameters [within the specification of a function/procedure] and in variable declarations. In the case of the specifications Procedure Push ( The_Stack : in out Stack; Value : in Integer ); and Procedure Push( Stack : in out Stack_Type; Value in Integer ); are not all that different; where the 'noise' comes in is the only difference; in one it attaches to the parameter-type portion of the declaration, in the other it attaches to the parameter-name portion. To my thinking there will often be many more calls to the procedure comparative to the number of times it is declared [perhaps twice, once in the spec and once in the body]; this argument applies within the procedure itself AND with regard to variable declaration/usage. Very rarely will you declare a variable and not use it; opposed to the common case of using a variable multiple times to its one declaration. > > S/W engineering involves putting in the effort to think of good names for > everything in your code. "_Type" is a kludge to avoid doing that thinking= . > True enough. However, there is the argument that the "_Type" 'kludge' is a valid way of presenting a publicly-visible/usable spec to your user in such a way as to reduce ambiguity; see above. What we're seeing is the first-cousin of the "class of type" vs "object of [class of] type" phenomena; the two are distinct ideas yet intimately linked. > In this case, the type defines the information for dealing with a Charact= er, so > I'd probably use Character_Info as the type name. Perfectly valid choice.