comp.lang.ada
 help / color / mirror / Atom feed
From: "Robert I. Eachus" <eachus@mitre.org>
Subject: Re: Self-referential types
Date: 1999/10/18
Date: 1999-10-18T22:28:17+00:00	[thread overview]
Message-ID: <380BA036.E9F51F22@mitre.org> (raw)
In-Reply-To: 7u86su$o5v$1@nntp8.atl.mindspring.net

   It is nice to be so respectfully disagreed with by so many people,
and so
quickly too. ;-)  However, I don't think they are really disagreeing
with my point, just with the words I used to say it.

   Let's say you have an otherwise large subprogram, with a lot of
complexity and a lot of hidden scope variables and data, you have two
choices of how to implement it:

   You can create a procedure or function with a lot of other nested
subprograms, or

   You can create a package with the shared state in the body, and the
previous complex procedure as a public interface to that package.

   In Ada you should almost always (there are those words again) choose
the later.  The exceptions tend to be those cases where the enclosing
subprogram has lots of record or array parameters.  But that is normaly
bad programming practice.

   To specifically address Richard Riehle's comments, I tend to do the
same thing as he does with case statements, but I unnest the case
alternatives and put them in a package.  If there is local state needed
from the enclosing procedure, I make it a generic package and
instantiate it locally to pass the parameters of the enclosing
procedure.

   Doing all this takes effort.  You have to think about what state is
getting passed where.  (Unless, of course, you did all that right during
detailed design. ;-) I refuse to see that as anything other than a
benefit.  I can't begin to count the number of times I have caught
subtle programming or design bugs this way, and of course the
maintenance programmer will love you for it.  Well, maybe that is a bit
strong.  Certainly he or she won't detest you, and may even say hello in
the hallway or the cafeteria.  Of course, if you get stuck with the
maintenance job, you will find yourself saying, "Gee, I'm glad I did
this right," rather than "What the hell was I thinking when I wrote
this."

  I could give examples, but why bother.  Everyone reading this must
have had the experience of a subtle bug caused by undocumented (and
usually unintended) coupling between otherwise unrelated units.
   
-- 

                                        Robert I. Eachus

with Standard_Disclaimer;
use  Standard_Disclaimer;
function Message (Text: in Clever_Ideas) return Better_Ideas is...




  parent reply	other threads:[~1999-10-18  0:00 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <7ttb4a$8mq$1@nnrp1.deja.com>
     [not found] ` <3802597B.9205AEE8@averstar.com>
1999-10-12  0:00   ` Self-referential types Ted Dennison
1999-10-12  0:00     ` Matthew Heaney
1999-10-13  0:00       ` Ted Dennison
1999-10-12  0:00 ` Robert A Duff
1999-10-12  0:00 ` Vladimir Olensky
1999-10-12  0:00   ` Matthew Heaney
1999-10-12  0:00     ` Robert I. Eachus
1999-10-12  0:00       ` Matthew Heaney
1999-10-13  0:00         ` Ted Dennison
1999-10-13  0:00           ` Matthew Heaney
1999-10-13  0:00         ` Vladimir Olensky
1999-10-13  0:00           ` Vladimir Olensky
1999-10-18  0:00           ` Robert Dewar
1999-10-18  0:00             ` Laurent Guerby
1999-10-18  0:00             ` Vladimir Olensky
1999-10-13  0:00         ` Robert I. Eachus
1999-10-13  0:00           ` Brian Rogoff
1999-10-15  0:00             ` Robert I. Eachus
1999-10-15  0:00               ` Marin David Condic
1999-10-15  0:00                 ` Robert I. Eachus
1999-10-18  0:00                   ` Robert Dewar
1999-10-19  0:00                     ` Robert I. Eachus
     [not found]               ` <7u86su$o5v$1@nntp8.atl.mindspring.net>
1999-10-18  0:00                 ` Robert I. Eachus [this message]
1999-10-22  0:00                   ` Richard D Riehle
1999-10-22  0:00                     ` Robert I. Eachus
1999-10-18  0:00               ` Robert Dewar
1999-10-18  0:00                 ` Ed Falis
1999-10-19  0:00                   ` Robert Dewar
1999-10-18  0:00                 ` Brian Rogoff
     [not found]               ` <slrn80fl9f.68j.aidan@skinner.demon.co.uk>
1999-10-19  0:00                 ` Wes Groleau
1999-10-21  0:00                   ` Robert Dewar
1999-10-21  0:00                     ` Jean-Pierre Rosen
1999-10-21  0:00                       ` Robert Dewar
1999-10-21  0:00                     ` Larry Kilgallen
1999-10-21  0:00                     ` Comments (was: Self-referential types) Wes Groleau
1999-10-21  0:00                       ` Ehud Lamm
1999-10-22  0:00                         ` Ted Dennison
1999-10-23  0:00                           ` Ehud Lamm
1999-10-23  0:00                         ` Robert Dewar
1999-10-23  0:00                           ` Ehud Lamm
1999-10-23  0:00                             ` Comments Georg Bauhaus
1999-10-24  0:00                               ` Comments Ehud Lamm
1999-10-26  0:00                                 ` Comments Robert I. Eachus
1999-10-28  0:00                                   ` Comments Jerry van Dijk
1999-10-28  0:00                                     ` Comments Ted Dennison
1999-10-25  0:00                             ` Comments (was: Self-referential types) Wes Groleau
1999-10-23  0:00                       ` M.
     [not found]                       ` <Pine.A41.3.96-heb-2.07.991021191504.30582K-100000@pluto.mscc.huji. <381477c9.e1388ff3@ftw.rsc.raytheon.com>
1999-10-25  0:00                         ` Larry Kilgallen
1999-10-22  0:00                     ` Self-referential types Richard D Riehle
1999-10-23  0:00                       ` Robert A Duff
1999-10-23  0:00                         ` Richard D Riehle
1999-10-24  0:00                       ` Michel DELARCHE
1999-10-12  0:00     ` Ted Dennison
1999-10-12  0:00       ` Matthew Heaney
1999-10-12  0:00     ` Richard D Riehle
1999-10-12  0:00     ` news.oxy.com
1999-10-12  0:00       ` Ted Dennison
1999-10-12  0:00         ` Stanley R. Allen
1999-10-13  0:00           ` Ted Dennison
1999-10-13  0:00         ` Vladimir Olensky
1999-10-14  0:00         ` Multiple Inheritance in Ada 95 [was Re: Self-referential types] Tucker Taft
1999-10-12  0:00       ` Self-referential types Matthew Heaney
replies disabled

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