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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,2afac1a4161c7f35 X-Google-Attributes: gid103376,public From: adam@irvine.com (Adam Beneschan) Subject: Re: Distinguishing type names from other identifiers Date: 1998/01/13 Message-ID: <884736089.2104295427@dejanews.com>#1/1 X-Deja-AN: 315693986 X-Originating-IP-Addr: 192.160.8.44 (dogbert.irvine.com) X-Authenticated-Sender: adam@irvine.com (Adam Beneschan) X-Http-User-Agent: Mozilla/3.0 (X11; I; Linux 2.0.18 i586) Organization: Deja News Posting Service X-Article-Creation-Date: Wed Jan 14 00:01:30 1998 GMT Newsgroups: comp.lang.ada Date: 1998-01-13T00:00:00+00:00 List-Id: Nick Roberts wrote: > The technique I generally use for inventing a type identifier distinct from > identifiers I might use for objects and parameters of that type is to make > the type identifier one step more specific (and thus, usually, longer). > > The justification for using a longer identifier for the type, rather than > for the objects and parameters, is that type identifiers are generally used > less often in practical source text. > > For example: > > type Hour_Of_Day is range 0..23; > type Minute_Of_Hour is range 0..59; > type Seconds_Past_Minute is delta 0.001 range 0.000 .. 59.999; > > function To_Seconds_Past_Midnight > (Hour: Hour_Of_Day; > Minute: Minute_Of_Day; > Seconds: Seconds_Past_Minute) return Day_Duration; > > This example illustrates (I hope ;-) that the use of a plural or singular > form for an identifier is not naturally to do with whether it denotes a > type, an object, a parameter, a subprogram, or whatever, but rather with > whatever concept it describes. The choice of Seconds_Past_Minute is > perhaps a little clumsy. . . . After following this thread, and looking at this example, I really wonder what the objection is to using _Type suffixes. Several people have objected to "_Type" on the ground that it doesn't add any informational value to the name. But do the extra words in the above example add any value to the name, either? I'm not convinced that calling the type Hour_Of_Day is any more helpful to a programmer than just calling it Hour or Hour_Type. Of course, I could have picked a bad example to complain about, since there could be a use for both "Minute_Of_Hour" and "Minute_Of_Day" or "Minute_Of_Year" or "Minutes_Elapsed" types, or something like that. But it seems to me that in many, many cases, there just isn't any extra value to add to the name. So *anything* you add, whether it's a boring suffix like _Type or a boring prefix like The_, or something less boring that appears to contain additional information as in the above example, is still just "noise"---in essence, a kludge to keep the compiler happy. So if I'm right and anything you add is just noise, I think it may be best to use a boring suffix like _Type. The small advantage to this is that it may make your names easier to remember. If you use _Type consistently, at least you have less information to carry around in your head, instead of trying to remember something different for each type: "Now, let's see, did I call this one _Number, or _Of_Day, or _Of_Hour, or what?" leading to potential errors such as the one Nick included in his above example. -- Adam -------------------==== Posted via Deja News ====----------------------- http://www.dejanews.com/ Search, Read, Post to Usenet