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: mheaney@ni.net (Matthew Heaney) Subject: Re: Two simple language questions (plural types) Date: 1998/01/12 Message-ID: #1/1 X-Deja-AN: 315280414 Content-Transfer-Encoding: 8bit References: <199801121523.QAA06527@basement.replay.com> Content-Type: text/plain; charset=ISO-8859-1 Organization: Estormza Software Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1998-01-12T00:00:00+00:00 List-Id: In article <199801121523.QAA06527@basement.replay.com>, nobody@REPLAY.COM (Anonymous) wrote: >> Hallelujah! Robert, once again you bring order to chaos. I completely >> agree that plural names should be used to denote, well, plural objects - >> aggregates of some kind. For example, if I have a color object that stores >> the value of a single color, then of course the singular declaration >> >> The_Color : Color; >> >However, this is a lot of objective evidence that shows that common >prefixes are bad. The first few characters of names are the most >important in telling names apart; if all variable names in a program >start with a common prefix ("The_"), then it is harder to tell the >variables apart. This is not opinion; it is fact. > >The origin of "The_" for all parameters seems to come from books by >someone who could not come up with good type names, and so used the >preferred form for the parameter name for the type name, leaving nothing >good for the parameter name. (I don't have any of the books available, >so I can't be sure about variable names.) Those who advocate plurals for >type names are generally also unable to create good type names, but they >at least want to keep the best form for parameters/variables. > >I also object to the use of suffixes that add no information to the name >("_Type", "_T"); this is just another kludge by those who cannot create >good type names. Perhaps I chose a bad example. I occasionally use a definate article on object names, I mostly do not. I agree also that one does not require the "_Type" suffix on type names. The designator _Type doesn't add any more value to the name, since it appears on the right-hand side of a declaration, and therefore I already know it's a type. But you have to solve the problem of giving objects a different name than the type, because they share the same namespace (this is not an issue in Eiffel). So I usually name types using a two-part phrase comprising a noun and adjective, and then name the object just using the noun part. For example, in Text_IO we have type File_Mode is ... It's not called Mode_Type, it's called File_Mode. So now your selector can read function Mode (File : File_Type) return File_Mode; Object declarations can now read Mode : File_Mode; and so no prefix is required, and All The People Were Happy. In fact, I think the reason the _Type convention is a debate in the Ada community is because the file type declared in Text_IO was named type File_Type is limited private; To me, this is the one thing the designers got wrong, because they're not consistant with other declarations in the RM. The file types should have been named type Text_File is type Sequential_File is type Direct_File is and so once again we could declare a file object as File : Text_File; It is not clear to me why the original language designers chose this convention for the predefined file types. After all, File_Mode isn't called Mode_Type Integer isn't called Integer_Type Float isn't called Float_Type String isn't called String_Type so why is Text_File called File_Type? For general, non-specific types, a one-word name is OK, because you're going to name the selector and the object using a different, more specific name, ie function Name (File : File_Type) return String; Name : String; But what about color? I would have used the two-part technique, and qualified that name by the abstraction for which it is an attribute, ie type Car_Color is ... so that I could write Color : Car_Color; No prefix is therefore required. -------------------------------------------------------------------- Matthew Heaney Software Development Consultant (818) 985-1271