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.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!news.uzoreto.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: Type naming conventions: Any_Foo Date: Thu, 5 Dec 2019 23:33:52 +0200 Organization: Tidorum Ltd Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: individual.net cksk+Ce6qSLOuPjEM+1J5wCT4zuWL/Jf4gyM74x4DBfAFuL63v Cancel-Lock: sha1:6arL7RedHsLdjHt3AkIxHuuNmxo= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.2.1 In-Reply-To: Content-Language: en-US Xref: reader01.eternal-september.org comp.lang.ada:57662 Date: 2019-12-05T23:33:52+02:00 List-Id: 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 . @ .