comp.lang.ada
 help / color / mirror / Atom feed
From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: Type naming conventions: Any_Foo
Date: Thu, 5 Dec 2019 23:33:52 +0200
Date: 2019-12-05T23:33:52+02:00	[thread overview]
Message-ID: <h4tbe0Fda0kU1@mid.individual.net> (raw)
In-Reply-To: <qsbqcf$41q$1@dont-email.me>


On 2019-12-05 22:47, Jeffrey R. Carter wrote:
> On 12/5/19 8:49 PM, Niklas Holsti wrote:
>>
>> Either of those is itself defining a convention. It seems every 
>> enumerated type would then get an "_ID" or "_Name" suffix. Or 
>> something similar.
> 
> Many enumeration types are identifiers or names; some are not.

I don't really agree with that "many", but it is perhaps a subjective 
issue -- how one thinks of an enumeration.

But if a value of the type Weapon_Id is an identifier of a Weapon, how 
can you defend saying

    Weapon : Weapon_Id;

The variable Weapon does not represent a Weapon; it represents an 
identifier of a Weapon, so the name Weapon is IMO a little misleading.

> A convention would end every enumeration type name with the same suffix, 
> even when it's not appropriate. Well chosen type names would perhaps 
> result in many such names ending in the same suffix, but not all.
> 
> As an example, the PragmAda Reusable Components have 13 lines returned by
> 
> grep -i "type  *[a-z0-9_]*  *is  *(" *.ad?
> 
> 8 of them end in _I[Dd] (I really should make the casing consistent), 1 
> in _Name, and 4 others.

Thanks for sharing this statistic.

(And yes, the issue of "ID" vs "Id" is a wide-spread annoyance. I tend 
to think that "ID" is an acronym for "Identification Document", while 
"Id" is an abbreviation for "Identifier". Obviously "Id" is more often 
apt for SW.)

> Had I used the convention of _ID rather than making the effort to
> think of good names, about 1/3 of those names would be less
> meaningful.
I agree with that, of course.

> Had I used a meaningless convention like _T for all 
> type names, all of those names would be less meaningful.

I don't agree with that, and of course I would include "_Id" or "_Name" 
or whatever is appropriate and meaningful, before the "_T".

> Meaningful names are easier to read, and ease of reading is an
> important goal of  S/W engineering.

Hell yes. But for me, the "_T" helps that goal, by letting me say either

    Weapon : Weapon_T;

or

    Weapon_Id : Weapon_Id_T;

depending on the case at hand.

-- 
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
       .      @       .


  reply	other threads:[~2019-12-05 21:33 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-04 13:56 Type naming conventions: Any_Foo Alejandro R. Mosteo
2019-12-04 14:52 ` Lucretia
2019-12-04 16:42   ` Alejandro R. Mosteo
2019-12-05 10:51     ` AdaMagica
2019-12-05 17:27       ` Jeffrey R. Carter
2019-12-05 17:45         ` Dmitry A. Kazakov
2019-12-05 20:03           ` Jeffrey R. Carter
2019-12-05 21:51             ` Dmitry A. Kazakov
2019-12-05 23:12               ` Randy Brukardt
2019-12-06 20:20                 ` Jeffrey R. Carter
2019-12-07  1:19                   ` Randy Brukardt
2019-12-06 20:18               ` Jeffrey R. Carter
2019-12-06 20:35                 ` Dmitry A. Kazakov
2019-12-07  0:57                   ` Randy Brukardt
2019-12-07 10:28                     ` Jeffrey R. Carter
2019-12-07 12:36                       ` Niklas Holsti
2019-12-08 12:04                         ` Jeffrey R. Carter
2019-12-07 10:13                   ` Jeffrey R. Carter
2019-12-07 11:21                     ` Dmitry A. Kazakov
2019-12-08 11:55                       ` Jeffrey R. Carter
2019-12-08 12:38                         ` Dmitry A. Kazakov
2019-12-08 14:31                         ` Shark8
2019-12-08 21:58                           ` Jeffrey R. Carter
2019-12-09 22:47                             ` Shark8
2019-12-07 23:24                     ` Jere
2019-12-08 12:14                       ` Jeffrey R. Carter
2019-12-09 22:07                         ` Randy Brukardt
2019-12-05 19:49         ` Niklas Holsti
2019-12-05 20:47           ` Jeffrey R. Carter
2019-12-05 21:33             ` Niklas Holsti [this message]
2019-12-06 11:44               ` Lucretia
2019-12-06 20:23                 ` Jeffrey R. Carter
2019-12-06 20:11               ` Jeffrey R. Carter
2019-12-06 20:46                 ` Dmitry A. Kazakov
2019-12-06 21:55                 ` Niklas Holsti
2019-12-07 10:19                   ` Jeffrey R. Carter
2019-12-07 12:05                     ` Niklas Holsti
2019-12-08 11:59                       ` Jeffrey R. Carter
2019-12-06  8:57       ` AdaMagica
2019-12-06  9:55         ` J-P. Rosen
2019-12-06 15:30       ` Optikos
2019-12-07  3:34 ` Shark8
replies disabled

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