comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Carter <spam@spam.com>
Subject: Re: Naming convention for classes?
Date: Wed, 04 Feb 2004 00:27:18 GMT
Date: 2004-02-04T00:27:18+00:00	[thread overview]
Message-ID: <G%WTb.12124$uM2.2382@newsread1.news.pas.earthlink.net> (raw)
In-Reply-To: <MPG.1a89fe0b56e324d998968e@news.sover.net>

Peter C. Chapin wrote:

> package Date is
>   type Object is private;
> 
>   procedure Advance(Item : in out Object; Step : in Integer);
>   ...
> end Date;
> 
> The I can create Date objects by first withing Date and then doing
> 
>   Today : Date.Object;
>   ...
>   Date.Advance(Today, 100);
> 
> package My_Library is
>   type Date is private;
> 
>   procedure Advance(Item : in out Date; Step : in Integer);
>   ...
> end My_Library;
> 
> Then I might with My_Library and use My_Library and do
> 
>   Today : Date;
>   ...
>   Advance(Today, 100);

Is this a troll? You'll find ample discussion of this (naming types and 
packages) if you search c.l.a at groups.google.com. Some people are very 
attached to one approach or the other.

The 2 approaches you mention are called "use unfriendly" and "use 
friendly", respectively. There are arguments for and against both 
approaches. Ada's standard packages are use friendly. For example, 
package Ada.Strings.Unbounded declares type Unbounded_String.

If you create use friendly packages, you should not consider the package 
name to be noise. "Ada.Strings.Unbounded" is not just noise.

One approach is to use appropriate suffixes to create useful names:

package Date_Handling is
    type Date_Info is private;

    procedure Advance (Date : in out Date_Info; Num_Days : in Positive);

Note that with this approach the reader can tell that you're advancing a 
date by a number of days without any comments. Note also that negative 
numbers of days are not allowed, as that would not be considered 
advancing a date.

-- 
Jeff Carter
"Your mother was a hamster and your father smelt of elderberries."
Monty Python & the Holy Grail
06




  reply	other threads:[~2004-02-04  0:27 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-03 23:52 Naming convention for classes? Peter C. Chapin
2004-02-04  0:27 ` Jeffrey Carter [this message]
2004-02-04  2:31   ` Peter C. Chapin
2004-02-04  8:57     ` Jean-Pierre Rosen
2004-02-04 11:52       ` Peter C. Chapin
2004-02-04 14:02         ` Jean-Pierre Rosen
2004-02-05 12:18           ` Stuart Palin
2004-02-04 14:13         ` Martin Krischik
2004-02-04  9:13     ` Preben Randhol
2004-02-04 14:57     ` Georg Bauhaus
2004-02-04 19:01     ` Jeffrey Carter
2004-02-04  8:06 ` tmoran
2004-02-04 11:49   ` Peter C. Chapin
2004-02-04 12:36     ` Preben Randhol
2004-02-04 12:41       ` Preben Randhol
2004-02-04 14:09       ` Martin Krischik
replies disabled

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