comp.lang.ada
 help / color / mirror / Atom feed
From: mheaney@ni.net (Matthew Heaney)
Subject: Re: Two simple language questions (plural types)
Date: 1998/01/12
Date: 1998-01-12T00:00:00+00:00	[thread overview]
Message-ID: <mheaney-ya023680001201981007080001@news.ni.net> (raw)
In-Reply-To: 199801121523.QAA06527@basement.replay.com


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
<mailto:matthew_heaney@acm.org>
(818) 985-1271




  reply	other threads:[~1998-01-12  0:00 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-01-07  0:00 Two simple language questions Chip Richards
1998-01-07  0:00 ` Matthew Heaney
1998-01-10  0:00   ` Two simple language questions (plural types) Michael F Brenner
1998-01-10  0:00     ` Robert Dewar
1998-01-10  0:00       ` Matthew Heaney
1998-01-10  0:00         ` Robert Dewar
1998-01-12  0:00         ` Anonymous
1998-01-12  0:00           ` Matthew Heaney [this message]
1998-01-12  0:00             ` Brian Rogoff
1998-01-13  0:00               ` Robert Dewar
1998-01-13  0:00                 ` Distinguishing type names from other identifiers Nick Roberts
1998-01-13  0:00                   ` Matthew Heaney
1998-01-14  0:00                     ` Stephen Leake
1998-01-24  0:00                       ` Matthew Heaney
1998-01-15  0:00                     ` Anonymous
1998-01-24  0:00                       ` Matthew Heaney
1998-01-24  0:00                         ` Martin M Dowie
1998-01-24  0:00                           ` Pred Nick Roberts
1998-01-25  0:00                           ` Distinguishing type names from other identifiers Matthew Heaney
1998-01-24  0:00                         ` Martin M Dowie
1998-01-15  0:00                   ` Aaro Koskinen
1998-01-17  0:00                     ` Martin M Dowie
1998-01-17  0:00                       ` Martin M Dowie
1998-01-25  0:00                       ` Matthew Heaney
1998-01-25  0:00                         ` Brian Rogoff
     [not found]                         ` <n5rs5FAStOz0Ew2+@dowie-cs.demon.co.uk>
1998-01-26  0:00                           ` Brian Rogoff
1998-01-27  0:00                             ` Martin M Dowie
1998-01-27  0:00                               ` Brian Rogoff
1998-01-27  0:00                                 ` Matthew Heaney
1998-01-28  0:00                                   ` Brian Rogoff
1998-01-28  0:00                                     ` Matthew Heaney
1998-01-29  0:00                                       ` Brian Rogoff
1998-01-30  0:00                                     ` Mats Weber
1998-01-28  0:00                                 ` Martin M Dowie
1998-01-12  0:00           ` Two simple language questions (plural types) Brian Rogoff
1998-01-11  0:00     ` Brian Rogoff
1998-01-07  0:00 ` Two simple language questions Robert Dewar
1998-01-07  0:00 ` Tucker Taft
1998-01-07  0:00 ` Dale Stanbrough
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox