comp.lang.ada
 help / color / mirror / Atom feed
* Tagged type naming convention
@ 2017-11-04 16:50 Jere
  2017-11-04 23:43 ` Luke A. Guest
  2017-11-05 19:01 ` Jacob Sparre Andersen
  0 siblings, 2 replies; 5+ messages in thread
From: Jere @ 2017-11-04 16:50 UTC (permalink / raw)


I was looking at an older document for a naming convention 
for tagged types and stumbled upon J.P. Rosen's "A Naming 
Convention for Classes in Ada 9X" [1].  It's pretty intriguing
and, even though it was developed for 9X, it has applicability 
in the current Ada revision.  However, I haven't really seen it
employed in any of the libraries I've messed with.  Keep in 
mind, my experience with external libraries is limited.  I
was curious if this style is something that a lot of people
use and had some input on.  Is it still in use?  Pros/Cons based
on experience using it?  

One concern for it is consistency.  It was presented with tagged
types in mind, but even non tagged types provide inheritance and
primitive operations that can be overridden.  Should it be applied
to those as well if used?


[1] https://dl.acm.org/citation.cfm?id=224131&CFID=1001928767&CFTOKEN=61001405

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

* Re: Tagged type naming convention
  2017-11-04 16:50 Tagged type naming convention Jere
@ 2017-11-04 23:43 ` Luke A. Guest
  2017-11-07  0:32   ` Jere
  2017-11-05 19:01 ` Jacob Sparre Andersen
  1 sibling, 1 reply; 5+ messages in thread
From: Luke A. Guest @ 2017-11-04 23:43 UTC (permalink / raw)


Jere <jhb.chat@gmail.com> wrote:
use?  Pros/Cons based
> on experience using it?  
> 
> One concern for it is consistency.  It was presented with tagged

I use multiple for packages and single for types. Consistency is tricky. I
created a few interfaces today and used Drawables for package and Drawable
for the interface.


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

* Re: Tagged type naming convention
  2017-11-04 16:50 Tagged type naming convention Jere
  2017-11-04 23:43 ` Luke A. Guest
@ 2017-11-05 19:01 ` Jacob Sparre Andersen
  2017-11-07  0:43   ` Jere
  1 sibling, 1 reply; 5+ messages in thread
From: Jacob Sparre Andersen @ 2017-11-05 19:01 UTC (permalink / raw)


Jere <jhb.chat@gmail.com> writes:

> I was looking at an older document for a naming convention for tagged
> types and stumbled upon J.P. Rosen's "A Naming Convention for Classes
> in Ada 9X" [1].  It's pretty intriguing and, even though it was
> developed for 9X, it has applicability in the current Ada revision.
> However, I haven't really seen it employed in any of the libraries
> I've messed with.  Keep in mind, my experience with external libraries
> is limited.  I was curious if this style is something that a lot of
> people use and had some input on.  Is it still in use?  Pros/Cons
> based on experience using it?

It is definitely still in use.  I use it.

> One concern for it is consistency.  It was presented with tagged types
> in mind, but even non tagged types provide inheritance and primitive
> operations that can be overridden.  Should it be applied to those as
> well if used?

Only if you stick to the pattern of a single type per package.

I only use Jean-Pierres's naming pattern for the primary type in a
package.  Any "helper" types have more arbitrary names.

Jean-Pierre's naming pattern is one of the two suggested in the Ada 95
Quality and Style Guide.

Greetings,

Jacob
-- 
Better save than sorry!

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

* Re: Tagged type naming convention
  2017-11-04 23:43 ` Luke A. Guest
@ 2017-11-07  0:32   ` Jere
  0 siblings, 0 replies; 5+ messages in thread
From: Jere @ 2017-11-07  0:32 UTC (permalink / raw)


On Saturday, November 4, 2017 at 7:43:07 PM UTC-4, Luke A. Guest wrote:
> Jere wrote:
> use?  Pros/Cons based
> > on experience using it?  
> > 
> > One concern for it is consistency.  It was presented with tagged
> 
> I use multiple for packages and single for types. Consistency is tricky. I
> created a few interfaces today and used Drawables for package and Drawable
> for the interface.

That is currently what I do (or I have a more descriptive package name if 
it makes sense to do so.  I like this method.  I was thinking of 
incorporating it with the Rosen method (see my response to Jacob 
Sparre Anderson).  I haven't sold myself on that yet though.


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

* Re: Tagged type naming convention
  2017-11-05 19:01 ` Jacob Sparre Andersen
@ 2017-11-07  0:43   ` Jere
  0 siblings, 0 replies; 5+ messages in thread
From: Jere @ 2017-11-07  0:43 UTC (permalink / raw)


On Sunday, November 5, 2017 at 2:01:02 PM UTC-5, Jacob Sparre Andersen wrote:
> Jere writes:
> 
> > I was looking at an older document for a naming convention for tagged
> > types and stumbled upon J.P. Rosen's "A Naming Convention for Classes
> > in Ada 9X" [1].  It's pretty intriguing and, even though it was
> > developed for 9X, it has applicability in the current Ada revision.
> > However, I haven't really seen it employed in any of the libraries
> > I've messed with.  Keep in mind, my experience with external libraries
> > is limited.  I was curious if this style is something that a lot of
> > people use and had some input on.  Is it still in use?  Pros/Cons
> > based on experience using it?
> 
> It is definitely still in use.  I use it.
That's good to hear.  It does look like a nice pattern.

> 
> > One concern for it is consistency.  It was presented with tagged types
> > in mind, but even non tagged types provide inheritance and primitive
> > operations that can be overridden.  Should it be applied to those as
> > well if used?
> 
> Only if you stick to the pattern of a single type per package.
> 
> I only use Jean-Pierres's naming pattern for the primary type in a
> package.  Any "helper" types have more arbitrary names.
> 
> Jean-Pierre's naming pattern is one of the two suggested in the Ada 95
> Quality and Style Guide.

I actually have a couple of use cases where I might have multiple "main"
types in a package.  Given that possibility and also the possibility that
I might want to define non-primative operations on a given type, I was
tossing around the idea of merging the Rosen method with the one mentioned
by Luke Guest.  Something like:

package Well_Named_Package is
   
   package A_Main_Type is
      
      type Instance is tagged private;
      subtype Class is Instance'Class;

      procedure Primitive_Op1(Object : Instance);
      procedure Primitive_Op2(Object : Instance);

   end A_Main_Type;

   package Another_Main_Type is
      
      type Instance is tagged private;
      subtype Class is Instance'Class;

      procedure Primitive_Op1(Object : Instance);
      procedure Primitive_Op2(Object : Instance);

   end Another_Main_Type;

   procedure Non_Primitive_Op1(Object : A_Main_Type.Instance);
   procedure Non_Primitive_Op2(Object : Another_Main_Type.Instance);
   procedure Non_Primitive_Op3
     (Object1 : A_Main_Type.Instance;
      Object2 : Another_Main_Type.Instance);
   
end Well_Named_Package;

My main concern is that starts to look complex/noisy.  But it gives me the
ability to have multiple main types and keep the same naming convention.

If I did that, however, I would want to keep packages with single main
types looking consistent.  At worst I would have something like this:


package Well_Named_Package is
   
   package A_Main_Type is
      
      type Instance is tagged private;
      subtype Class is Instance'Class;

      procedure Primitive_Op1(Object : Instance);
      procedure Primitive_Op2(Object : Instance);

   end A_Main_Type;
   
end Well_Named_Package;

So then I would have a package in a package with no indication
of why other than it is there to have consistency with the 
general case (multiple types and non primitive ops).

Though I feel like I might be going overboard.


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

end of thread, other threads:[~2017-11-07  0:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-04 16:50 Tagged type naming convention Jere
2017-11-04 23:43 ` Luke A. Guest
2017-11-07  0:32   ` Jere
2017-11-05 19:01 ` Jacob Sparre Andersen
2017-11-07  0:43   ` Jere

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