comp.lang.ada
 help / color / mirror / Atom feed
From: Georg Bauhaus <bauhaus@futureapps.de>
Subject: Re: Ada Quality and Style book discussion ("_Type" suffix)
Date: Thu, 17 Nov 2005 12:34:01 +0100
Date: 2005-11-17T12:31:08+01:00	[thread overview]
Message-ID: <1132227241.9036.44.camel@sonnenregen> (raw)
In-Reply-To: <slrndno8ho.22e.bogus_addy@tango.mindfuq.org>

On Thu, 2005-11-17 at 04:23 +0000, Anonymous Coward wrote:


>    package Name_Collisions is
> 
>       type Day is (Monday, Tuesday,  Wednesday, Thursday,
>                    Friday, Saturday, Sunday);
> 
>       type Meters is new Float;
> 
>       type Feet is new Float;
> 
>       --Oops, can't use these enums, since they were hijacked for
>       --numerical specs.
>       --
>       type Length is (Feet, Meters, Miles);

I think rather than hijacking this is asking for thought:
In you system, in the same place, is Feet a type or an
enumeration literal? Rephrasing Simon's excellent question,
now what *is* the use of Feet in the same namespace? Is it the
best choice to overload Feet here? Is it good style to overload
Feet in the same block?

Is Length to be a collection of types, with the types logically
connected? If so, then why not express this in the program?

  type Length is new Float;

  type Feet is new Length;
  type Meters is new Length;
  type Miles is new Length;

(Yes, this is not an enumeration, but anaway, I'll rather have to
speculate what the intended use of the Length might be.)

Given the above definitions now, what is Meters'Base?
Could you use it like Length to some extent?

Or is Length intended to be a collection of type names?
Symbols a la Lisp?

What if you want to write something using the types' commonalities
and not caring about their specifics? Like in

  package Distance_IO is new Float_IO(Length);

Anyway, the units might be missing from the type definitions.


> I've worked on a project that prohibited use of "_Type", and name
> collisions like above were a regular irritation, forcing users to
> constantly workaround the problem by prefixing "A_" to objects that
> needed no specific nomenclature. 

Workarounds like A_, used throughout the whole program, seem
like laziness to me. They will take revenge later when the same
programmers no long remember the specific context of A_Thing.
What thing?

In a dozen lines or so, a single letter is not at all an
indication of C style hacking, but rather a well established
way of expressing things. Mathematicians do that, technicians
too, and scientist also.

   for D in Day loop
      if Is_Weekday(D) then
         Start_Machinery;
      end;
   end loop;

Anything wrong here with the choice of D?

When I see "The_Day" in e.g. a subprogram profile, I'm tempted
to think of the parameter to be just some day. Fine. Alternatively,

  procedure foo(Day: Day_Type);

requires that the Ada language is kind of extended by a syntax
rule affixing _Type to every type name. Otherwise the reader might
be forced to switch style contexts in the procedure body.
This will be due to the overloading of "Day", because as you have
explained, the word itself is capable of expressing either object
or type.


>  Needless to say, the code was quite
> ugly, because folks had to attach more junk to the identifier, and
> worse, there was no uniform pattern.

Yes, junk is an indication of lack of Q&S. Folks were too lazy
to choose good names guided by some good rules.
If the software is to be maintained for some time, and deadlines
permitting, choice of good names will be more pleasant and money
saving in the long run, I think.

>   Some people would do the "A_",
> others would resort to "_Object", and the more disciplined users would
> simply replace "_Type" with "_Kind" :]

Somehow this discussion reminds me of the type prefix notation
introduced in some Windows C programming books.

  lpszLastName;

"Worse is better" at work?






  parent reply	other threads:[~2005-11-17 11:34 UTC|newest]

Thread overview: 112+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-15 16:03 Request for comments on simple Ada program Maciej Sobczak
2005-11-15 17:43 ` Samuel Tardieu
2005-11-15 17:47   ` Samuel Tardieu
2005-11-15 21:28   ` Jacob Sparre Andersen
2005-11-15 21:53     ` Samuel Tardieu
2005-11-16  9:10       ` Anders Wirzenius
2005-11-15 21:55     ` Samuel Tardieu
2005-11-16  9:03     ` Niklas Holsti
2005-11-16 14:21       ` Jacob Sparre Andersen
2005-11-16 17:08         ` Niklas Holsti
2005-11-16  7:11   ` Brian May
2005-11-15 18:29 ` jimmaureenrogers
2005-11-15 19:33   ` tmoran
2005-11-16 14:46     ` jimmaureenrogers
2005-11-16 18:05       ` Martin Dowie
2005-11-16 19:54       ` tmoran
2005-11-15 18:52 ` Martin Krischik
2005-11-15 19:33 ` tmoran
2005-11-16  3:10   ` Ada Quality and Style book discussion Anonymous Coward
2005-11-16  4:09     ` tmoran
2005-11-16  5:49     ` Simon Wright
2005-11-16  7:03       ` Martin Dowie
2005-11-17  4:49         ` Anonymous Coward
2005-11-17  6:48           ` Martin Dowie
2005-11-17 11:45           ` Georg Bauhaus
2005-11-17 12:37             ` Stephen Leake
2005-11-17 13:24               ` Georg Bauhaus
2005-11-17 23:15                 ` Stephen Leake
2005-11-19 20:28                   ` Don't use the "use" clause Anonymous Coward
2005-11-19 20:35                     ` Ed Falis
2005-11-21 17:36                       ` David Emery
2005-11-21 19:20                         ` Ed Falis
2005-11-21 22:21                           ` David Trudgett
2005-11-21 22:51                             ` Ed Falis
2005-11-22  0:15                           ` Anonymous Coward
2005-11-23  4:09                             ` Ed Falis
2005-11-23 19:26                               ` tmoran
2005-11-19 21:48                     ` Dmitry A. Kazakov
2005-11-19 22:33                       ` Simon Wright
2005-11-19 23:40                       ` Anonymous Coward
2005-11-20 11:07                         ` Dmitry A. Kazakov
2005-11-20 19:50                       ` Jeffrey R. Carter
2005-11-20  2:53                     ` Stephen Leake
2005-11-20  3:57                       ` Anonymous Coward
2005-11-20 10:44                     ` Pascal Obry
2005-11-20 19:48                     ` Jeffrey R. Carter
2005-11-22  5:11                     ` greptree lou
2005-11-22  6:08                       ` greptree Simon Wright
2005-11-25  1:00                       ` greptree Björn Persson
2006-01-23 12:51                     ` Don't use the "use" clause adaworks
2006-01-23 20:21                       ` Jeffrey R. Carter
2006-01-24  2:27                         ` Stephen Leake
2006-01-24  3:32                           ` Ed Falis
2006-01-24  4:44                           ` Jeffrey R. Carter
2006-01-24 22:53                             ` Stephen Leake
2006-01-24  8:54                           ` Dmitry A. Kazakov
2006-01-24  9:48                             ` Martin Dowie
2006-01-24 10:28                               ` Dmitry A. Kazakov
2006-01-24 13:30                                 ` brian.b.mcguinness
2006-01-24 20:03                                   ` Simon Wright
2006-01-24 23:00                                   ` Stephen Leake
2006-01-25  4:58                                     ` Jeffrey R. Carter
2006-01-24 23:38                                 ` Randy Brukardt
2006-01-25 14:49                                   ` Dmitry A. Kazakov
2006-01-25 21:46                                     ` Randy Brukardt
2006-01-26  9:14                                       ` Dmitry A. Kazakov
2006-01-27  1:04                                         ` Randy Brukardt
2006-01-27 15:23                                           ` Dmitry A. Kazakov
2006-01-27 16:35                                             ` Georg Bauhaus
2006-01-27 23:09                                               ` Randy Brukardt
2006-01-27 23:18                                             ` Randy Brukardt
2006-01-28 10:41                                               ` Dmitry A. Kazakov
2006-01-24 22:55                             ` Stephen Leake
2006-01-24  9:42                           ` Martin Dowie
2006-01-24 23:02                             ` Stephen Leake
2006-01-25  9:14                               ` Martin Dowie
2006-01-25 11:01                             ` Peter Amey
2006-01-25 11:06                               ` Martin Dowie
2006-01-25 20:07                               ` Jeffrey R. Carter
2006-01-31  2:24                               ` Stephen Leake
2006-02-09  5:13                       ` Anonymous Coward
2005-11-17 20:55           ` Ada Quality and Style book discussion Simon Wright
2005-11-18  0:44             ` Larry Kilgallen
2005-11-19 20:56             ` Anonymous Coward
2005-11-19 22:41               ` Simon Wright
2005-11-20  0:03                 ` Anonymous Coward
2005-11-17  4:23       ` Ada Quality and Style book discussion ("_Type" suffix) Anonymous Coward
2005-11-17 10:51         ` Martin Dowie
2005-11-19 21:52           ` Anonymous Coward
2005-11-20 15:50             ` Martin Dowie
2005-11-17 11:34         ` Georg Bauhaus [this message]
2005-11-17 11:53           ` Martin Dowie
2005-11-17 13:26             ` Georg Bauhaus
2005-11-17 12:26           ` Brian May
2005-11-17 13:45             ` Martin Dowie
2005-11-17 14:22               ` Marc A. Criley
2005-11-17 14:50                 ` Martin Dowie
2005-11-18  3:04                 ` Brian May
2005-11-18  9:23                   ` Maciej Sobczak
2005-11-18 14:00                     ` Marc A. Criley
2005-11-18 11:48                   ` Java exception model. Was: " Peter C. Chapin
2005-11-18 13:18                     ` Dmitry A. Kazakov
2005-11-19 18:06                       ` Peter C. Chapin
2005-11-19 18:58                         ` Dmitry A. Kazakov
2005-11-21 22:38                           ` Brian May
2005-11-21 23:27                           ` Brian May
2005-11-18 22:33                   ` Simon Wright
2005-11-17 14:03             ` Hyman Rosen
2005-11-20 19:41         ` Jeffrey R. Carter
2005-11-20 20:43           ` Dmitry A. Kazakov
2005-11-21  0:00             ` Simon Wright
2005-11-16 13:51     ` Ada Quality and Style book discussion Marc A. Criley
replies disabled

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