comp.lang.ada
 help / color / mirror / Atom feed
* Naming conventions
@ 1987-11-13 23:10 Michael.Rissman
  0 siblings, 0 replies; 8+ messages in thread
From: Michael.Rissman @ 1987-11-13 23:10 UTC (permalink / raw)


I'm looking for standards or conventions covering naming of Ada entities
from packages to data types.  Send or post pointers, including contacts.
Thanks, Michael

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Naming conventions
@ 2002-07-25  1:48 Ryan Tarpine
  2002-07-25  2:51 ` Ted Dennison
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Ryan Tarpine @ 2002-07-25  1:48 UTC (permalink / raw)


Coming from C++, what I used to think of as a class (a type and its
associated methods) is now roughly equivalent to a package.  Whenever I
try to name a package, I use what I normally think of as the type
itself.  For example, I would put a vector type in a package Vector or a
regular expression type in a package Regular_Expression.  However, once
I name the package, I am at a loss for what to call the data type inside.

I've been appending '_Type' to the package names, making names like 
Vector_Type, but I don't think that is the Right Thing(TM).  I've been 
skimming the style guides (which I heartily recommend all newbies to 
do), and I've seen a little bit of calling the type simply Instance or 
Object.  When used with the package name this looks nice, such as 
Vector.Instance.  What do the Ada gurus normally do for this? :)

Don't worry I don't intend to spark any naming "religious wars" like
http://www.informatik.uni-stuttgart.de/ifi/ps/ada-doc/style_guide/sec_3a.html#3.2.4 

warns :)

Thank you,
Ryan

PS - For everyone new to Ada (like me), I will repeat that you
should check out the style guides!  See
http://www.informatik.uni-stuttgart.de/ifi/ps/ada-doc/style_guide/cover.html 

for the Ada95 one.  I also found "Ada95 Lessons Learned" at
http://www.magi.com/~wb/ada95.html but I haven't read it all yet.




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Naming conventions
  2002-07-25  1:48 Naming conventions Ryan Tarpine
@ 2002-07-25  2:51 ` Ted Dennison
  2002-07-25  3:11 ` tmoran
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Ted Dennison @ 2002-07-25  2:51 UTC (permalink / raw)


Ryan Tarpine wrote:
> Coming from C++, what I used to think of as a class (a type and its
> associated methods) is now roughly equivalent to a package.  Whenever I

A package with a tagged type in it, yes.

> regular expression type in a package Regular_Expression.  However, once
> I name the package, I am at a loss for what to call the data type inside.
> 
> I've been appending '_Type' to the package names, making names like 
> Vector_Type, but I don't think that is the Right Thing(TM).  I've been 

No, its not.

> skimming the style guides (which I heartily recommend all newbies to 
> do), and I've seen a little bit of calling the type simply Instance or 
> Object.  When used with the package name this looks nice, such as 
> Vector.Instance.  What do the Ada gurus normally do for this? :)

If you are into making "class" packages with nothing but the one tagged 
type in them, that is probably the way to go. It does look a tad dorky 
though.

Usually I find that if my package's only reason for existance isn't to 
provide one tagged type an appropriate name will present itself. 
Sometimes even then, you can get a better name than "instance" by taking 
it from further up the package hierarchy. Make sure to pay attention to 
how the names will look when fully specified. For example, 
"Ada.Strings.Unbounded.String" would be a far better type name that 
"Ada.Strings.Unbounded.Unbounded_String", and "Ada.Text_IO.File" would 
be much better than "Ada.Text_IO.File_Type". :-)


> Don't worry I don't intend to spark any naming "religious wars" like
> http://www.informatik.uni-stuttgart.de/ifi/ps/ada-doc/style_guide/sec_3a.html#3.2.4 
> 
> warns :)

They say the road to hell is paved with good intentions. I don't know 
about that though. After all, the road I'm on right now seems to be 
paved that way. Errr...wait a minute....






^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Naming conventions
  2002-07-25  1:48 Naming conventions Ryan Tarpine
  2002-07-25  2:51 ` Ted Dennison
@ 2002-07-25  3:11 ` tmoran
  2002-07-25  4:28 ` SteveD
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: tmoran @ 2002-07-25  3:11 UTC (permalink / raw)


> Coming from C++, what I used to think of as a class (a type and its
> associated methods) is now roughly equivalent to a package.
  No no!  Abjure such incorrect ideas!  An Ada "type ...  is ..."
and its associated ("primitive") methods is indeed a type.  A package
is at a higher level.  It may have no types at all (consider a
trigonometry function library), just one type, a couple of highly
related types, or even private types for internal use only.  Thus a
single package might contain a root bitmap type as well as child
Monochrome, VGA, Truecolor, etc types.  Or it might have both Socket
and Server types.

> I've been appending '_Type' to the package names, making names like
> Vector_Type, but I don't think that is the Right Thing(TM).
  Definitely not the Right Thing.  Try a package named Sound with
a type named Clip_Type and procedures
Play(X : in Clip_Type)
Record(X : out Clip_Type; Time : in Duration);
  Perhaps you also have a second package named Video with its own
Clip_Type, Play, and Record.
  Then when you use the packages you will have things like
Oh_Tannenbaum,
Noise_In_The_Night : Sound.Clip_Type;
Ghost_Picture : Video.Clip_Type;
  ...
Sound.Play(Oh_Tannenbaum);
  ...
if Motion_Detected then
  Sound.Record(Noise_In_The_Night, 60.0);
  Video.Record(Ghost_Picture, 60.0);
end if;

> and I've seen a little bit of calling the type simply Instance or Object.
  An instance or object is a single manifestation of a particular type.
eg, Apple_Count, Orange_Count, Back_Camera, or Front_Camera in
Apple_Count,
Orange_Count : Integer;
Back_Camera, Front_Camera : Security_Camera_Type;

>http://www.informatik.uni-stuttgart.de/ifi/ps/ada-doc/style_guide/cover.html
I think that's the "Ada Quality and Style" guide, which is good, and
which will not, I think, lead you astray (although I can't seem to
connect to the web site at the moment).



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Naming conventions
  2002-07-25  1:48 Naming conventions Ryan Tarpine
  2002-07-25  2:51 ` Ted Dennison
  2002-07-25  3:11 ` tmoran
@ 2002-07-25  4:28 ` SteveD
  2002-07-25 11:50 ` David C. Hoos, Sr.
  2002-07-25 15:20 ` Stephen Leake
  4 siblings, 0 replies; 8+ messages in thread
From: SteveD @ 2002-07-25  4:28 UTC (permalink / raw)


"Ryan Tarpine" <rtarpine@hotmail.com> wrote in message
news:3D3F58F4.9050305@hotmail.com...
> Coming from C++, what I used to think of as a class (a type and its
> associated methods) is now roughly equivalent to a package....

A package is closer to a C++ namespace than a class.  A C++ class
corresponds roughly to an Ada tagged type with its associated procedures and
functions.

>  Whenever I try to name a package, I use what I normally think of as the
type
> itself.  For example, I would put a vector type in a package Vector or a
> regular expression type in a package Regular_Expression.  However, once
> I name the package, I am at a loss for what to call the data type inside.
>
> I've been appending '_Type' to the package names, making names like
> Vector_Type, but I don't think that is the Right Thing(TM).  I've been
> skimming the style guides (which I heartily recommend all newbies to
> do), and I've seen a little bit of calling the type simply Instance or
> Object.  When used with the package name this looks nice, such as
> Vector.Instance.  What do the Ada gurus normally do for this? :)

If you want to follow this sort of convention, perhaps you should use:

package Vector_Package is

  type Vector_Type is abstract tagged null record with private;

  ...

etc.

I'm sure you'll get all kinds of feedback that this convention is bad, but
if
you're consistant and make things readable it really doesn't matter what
conventions you follow.

SteveD







^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Naming conventions
  2002-07-25  1:48 Naming conventions Ryan Tarpine
                   ` (2 preceding siblings ...)
  2002-07-25  4:28 ` SteveD
@ 2002-07-25 11:50 ` David C. Hoos, Sr.
  2002-07-25 15:20 ` Stephen Leake
  4 siblings, 0 replies; 8+ messages in thread
From: David C. Hoos, Sr. @ 2002-07-25 11:50 UTC (permalink / raw)



----- Original Message ----- 
From: "Ryan Tarpine" <rtarpine@hotmail.com>
Newsgroups: comp.lang.ada
To: <comp.lang.ada@ada.eu.org>
Sent: Wednesday, July 24, 2002 8:48 PM
Subject: Naming conventions


<snip>
Personally I like to use plural nouns for packages, and
singular nouns for types.

So, you might have package name Regular_Expressions,
and type name Regular_Expression.

However it is not illegal to use the same name for a type
as the name of the package in which it's declared.

For example the GNAT regular expression package is
named GNAT.Regexp, and the type name is Regexp.






^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Naming conventions
  2002-07-25  1:48 Naming conventions Ryan Tarpine
                   ` (3 preceding siblings ...)
  2002-07-25 11:50 ` David C. Hoos, Sr.
@ 2002-07-25 15:20 ` Stephen Leake
  2002-07-25 16:24   ` Jean-Pierre Rosen
  4 siblings, 1 reply; 8+ messages in thread
From: Stephen Leake @ 2002-07-25 15:20 UTC (permalink / raw)


Ryan Tarpine <rtarpine@hotmail.com> writes:

> Coming from C++, what I used to think of as a class (a type and its
> associated methods) is now roughly equivalent to a package.  Whenever I
> try to name a package, I use what I normally think of as the type
> itself.  For example, I would put a vector type in a package Vector or a
> regular expression type in a package Regular_Expression.  However, once
> I name the package, I am at a loss for what to call the data type inside.

Welcome to the club :).

> I've been appending '_Type' to the package names, making names like
> Vector_Type, but I don't think that is the Right Thing(TM). 

I would name the type using _Type:

package Vector is

    type Vector_Type is ... ;
end Vector;

That's a nice, simple convention. You don't have to think about it.

However, if you don't use 'use', it looks a little redundant. In that
case, just name the type 'T':

package Vector is
   type T is ...;
end Vector;

with Vector;
package Client is

    Velocity : Vector.T;

end Client;

Have fun!


-- 
-- Stephe



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Naming conventions
  2002-07-25 15:20 ` Stephen Leake
@ 2002-07-25 16:24   ` Jean-Pierre Rosen
  0 siblings, 0 replies; 8+ messages in thread
From: Jean-Pierre Rosen @ 2002-07-25 16:24 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 916 bytes --]


"Stephen Leake" <stephen.a.leake.1@gsfc.nasa.gov> a �crit dans le message news: u8z3zzvdx.fsf@gsfc.nasa.gov...
>
> > Coming from C++, what I used to think of as a class (a type and its
> > associated methods) is now roughly equivalent to a package.  Whenever I
> > try to name a package, I use what I normally think of as the type
> > itself.  For example, I would put a vector type in a package Vector or a
> > regular expression type in a package Regular_Expression.  However, once
> > I name the package, I am at a loss for what to call the data type inside.
>
See "A naming convention for classes in Ada 9X", Ada Letters Vol XV n� 2, for a discussion of a solution to this problem. You can
also download the paper from http://www.adalog.fr/publica2.htm

--
---------------------------------------------------------
           J-P. Rosen (rosen@adalog.fr)
Visit Adalog's web site at http://www.adalog.fr





^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2002-07-25 16:24 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-25  1:48 Naming conventions Ryan Tarpine
2002-07-25  2:51 ` Ted Dennison
2002-07-25  3:11 ` tmoran
2002-07-25  4:28 ` SteveD
2002-07-25 11:50 ` David C. Hoos, Sr.
2002-07-25 15:20 ` Stephen Leake
2002-07-25 16:24   ` Jean-Pierre Rosen
  -- strict thread matches above, loose matches on Subject: below --
1987-11-13 23:10 Michael.Rissman

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