comp.lang.ada
 help / color / mirror / Atom feed
From: Richard Riehle <richard@adaworks.com>
Subject: Re: Refactoring and Ada
Date: Mon, 04 Feb 2002 09:03:44 -0800
Date: 2002-02-04T16:57:11+00:00	[thread overview]
Message-ID: <3C5EBEF0.FFC7D48@adaworks.com> (raw)
In-Reply-To: mailman.1012825743.12465.comp.lang.ada@ada.eu.org

"David C. Hoos, Sr." wrote:

> ----- Original Message -----
> From: "Richard Riehle" <richard@adaworks.com>
> Newsgroups: comp.lang.ada
> To: <comp.lang.ada@ada.eu.org>
> Sent: February 03, 2002 10:32 PM
> Subject: Re: Refactoring and Ada
> <snip>
> > I still prefer renames clauses when only one or two operators  need direct
> > visibility.    Use type can be as dangerous as the full use clause under
> > some circumstances.
> >
> Could you give an example of such a circumstance, Richard?

My concern is that use type makes all the operators visible for a
given type.   I realize the compiler can resolve the overloading
issues, so that is not so much of a problem.

There are at least two concerns with use type.  One is the lack of
documentation/traceability when there are multiple types in an
implementation.   The other is the potential for making an error
during maintenance, or even during development.

If, we with three packages, Goofy, Mickey, and Minnie, each of which
has type defined as Bone, Cheese, and Crackers, respectively we could
make all the operators directly visible with,

            use type Goofy.Bone;
            use type Mickey.Cheese;
            use type Minnie.Crackers;

Throughout my algorithmic code, I might be applying operators to objects
of these types without the lucidity afforded by dot notation I would routinely
use for operations.  Since all operators are directly visible for all types
named in my use type clause,  there is some potential for confusion on the
part of a programmer who has never seen this program before.

No only that.   It turns out that the only arithmetic operators I want to allow
for objects of type Goofy are addition and subtraction.   The only comparison
operators I am using are equality and greater-than.   It would be a disaster, in

the given program if a maintenance programmer were to test for less-than when
I wanted greater-than.    By coding my declarations so only those operators
appropriate to my program are directly visible (i.e., through renaming), I can
exert more precise control over the future of that code.

I am sure you can see where I am going with this.   Certainly, in those cases
where
I really want all the operators to be directly visible, use type has some
virtue.  For
systems where safety is a concern and where one can take advantage of Ada's
control over directly visibility, I think renaming is still a virtuous option.

I suppose I am old fashioned, but I still like the package design in which the
appropriate operators for a type are explicitly coded, either directly or
through a renames, in a nested package so the client of that package can do
something such as use Goofy.Operators.   This has the effect of making only
those operators directly visible that are necessary for the client.   I think it

also has the effect of making the design more clear, the client units safer,
and the code more traceable.

Someone once said that "Every political systems contains within it the seeds of
its
own destruction."   The same can be said of good ideas added to programming
languages.  I rather doubt there is a Beaujolais effect hidden in the use type
clause,
but I think there can be other problems now and then.   We need to consider the
full
range of options available to us when deciding how to approach visibility issues

in Ada.     The very fact that we have more than one option for managing
visibility
is one of the great benefits of using Ada in the first place.

Richard Riehle









  reply	other threads:[~2002-02-04 17:03 UTC|newest]

Thread overview: 75+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-02-01 15:13 Refactoring and Ada Paul Anderson
2002-02-02 17:48 ` Nick Roberts
2002-02-02 20:36   ` Pat Rogers
2002-02-03  0:21     ` Nick Roberts
2002-02-03 13:53       ` Robert Dewar
2002-02-03 19:23         ` Nick Roberts
2002-02-04  2:17           ` Robert Dewar
2002-02-04 20:48             ` Nick Roberts
2002-02-04 22:31               ` Pat Rogers
2002-02-04 22:43                 ` Marin David Condic
2002-02-06  2:51                 ` Nick Roberts
2002-02-03 18:50       ` Simon Wright
2002-02-04  4:32     ` Richard Riehle
2002-02-04 12:28       ` David C. Hoos, Sr.
2002-02-04 17:03         ` Richard Riehle [this message]
2002-02-06 17:19           ` Robert A Duff
2002-02-04 17:59       ` Robert Dewar
2002-02-04 18:50         ` Pascal Obry
2002-02-05  1:07           ` Robert Dewar
2002-02-05  1:44         ` Richard Riehle
2002-02-06 17:42           ` Robert A Duff
2002-02-06 17:32         ` Robert A Duff
2002-02-07  8:45         ` Dr. Michael Paus
2002-02-07 13:54           ` Pat Rogers
2002-02-03 13:48   ` Robert Dewar
2002-02-03 19:38     ` Nick Roberts
2002-02-04  2:20       ` Robert Dewar
2002-02-08 21:21       ` Paul Anderson
2002-02-03  9:45 ` Volkert
2002-02-04  0:06 ` Refactoring and Ada (tool I'd like to have...) David Emery
2002-02-08  9:24 ` Refactoring and Ada Martin Dowie
2002-02-08 15:15   ` Ted Dennison
2002-02-08 15:52     ` Pat Rogers
2002-02-08 16:07       ` OT : " martin.m.dowie
2002-02-08 17:11         ` Pat Rogers
2002-02-09 19:46           ` martin.m.dowie
2002-02-09 23:04             ` Pat Rogers
2002-02-10 13:57               ` Martin Dowie
2002-02-08 16:06     ` martin.m.dowie
2002-02-08 17:07       ` Pat Rogers
2002-02-09 19:48         ` martin.m.dowie
2002-02-09 23:05           ` Pat Rogers
2002-02-10  1:30     ` Marc A. Criley
2002-02-10  2:58       ` tmoran
2002-02-11 15:27       ` Marin David Condic
2002-02-12 19:16         ` Simon Wright
2002-02-15 19:43           ` Marin David Condic
2002-02-15 20:33           ` Matthew Heaney
2002-02-15 21:40             ` Larry Kilgallen
2002-02-19 16:54               ` Matthew Heaney
2002-02-19 19:39                 ` Larry Kilgallen
2002-02-20  4:23                   ` Richard Riehle
2002-02-20  5:20                     ` Mark Biggar
2002-02-20  9:58                     ` Pat Rogers
2002-02-20 17:14                       ` Matthew Heaney
2002-02-20 17:18                         ` Pat Rogers
2002-02-20 18:08                           ` Matthew Heaney
2002-02-20 22:12                             ` Pat Rogers
2002-02-23 22:48                             ` Robert Dewar
2002-02-21  0:41                           ` Randy Brukardt
2002-02-21  1:31                             ` Pat Rogers
2002-02-22 14:37                             ` Pat Rogers
2002-02-22 21:23                               ` Randy Brukardt
2002-02-23 23:04                                 ` Robert Dewar
2002-02-25 20:26                                   ` Randy Brukardt
2002-02-23 23:21                                 ` Robert Dewar
2002-02-23 22:58                             ` Robert Dewar
2002-02-23 22:55                     ` Robert Dewar
2002-02-26  1:05                       ` Nick Roberts
  -- strict thread matches above, loose matches on Subject: below --
2002-02-05  6:15 Christoph Grein
2002-02-07 11:26 Christoph Grein
2002-02-07 18:31 ` Dr. Michael Paus
2002-02-08 12:45   ` Robert Dewar
2002-02-08 17:20     ` Dr. Michael Paus
2002-02-20  6:19 Christoph Grein
replies disabled

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