comp.lang.ada
 help / color / mirror / Atom feed
From: "Warren W. Gay VE3WWG" <ve3wwg@cogeco.ca>
Subject: Re: Need advice re package organization.
Date: Sat, 26 Jul 2003 11:27:16 -0400
Date: 2003-07-26T11:27:16-04:00	[thread overview]
Message-ID: <yaxUa.374$XK4.16279@read1.cgocable.net> (raw)
In-Reply-To: 3F228F3B.9020203@attbi.com

"Robert I. Eachus" <rieachus@attbi.com> wrote in message news:3F228F3B.9020203@attbi.com...
> Bobby D. Bryant wrote:
>
>  > Any suggestions, either for my specific example or for more general
>  > considerations?
>
> The "right" answer to this question tends to be heuristic.  One package
> is probably too few, one (child) package per final type may be too many.
>
> If your (final) object types are going to be composed of component
> types, you almost certainly want one set of packages of components, and
> another of objects.  I would start with that organization, and
> specialize using child packages if there are types that are difficult to
> implement, not generally used, or where collisions between operation
> names are going to cause problems when you have a use clause for the
> main package.
>
> Figuring out the best organization is tough, and often you will discover
> a problem with the hierarchy you have chosen once you start implementing
> it.  Don't worry, go ahead and change it.  That is what text editors are
> for.  You don't need to find the perfect decomposition, just avoid bad
> ones.  And a bad decomposition shows up when it starts making work for
> you, rather than eliminating it.
>
> Of course, whatever organization you choose, you should sketch it out
> first, write the package specs, the main program, and then the package
> bodies.

All of this is good advice. When structuring your packages, keep in the
back of your mind the visibility and access rules that Ada insists upon.
For example, you'll have to avoid any circular package references (a
poor hierarchy will have a package trying to with a package that has
already been with-ed by it, creating a circular dependency). Another
catch may be a "support" package, that cannot gain access to the
necessary types of a set of parent/child packages (due to circular
references).

Parent/child package relationships themselves can get tricky. From a
software design perspective, you want to limit visibility for safety,
and yet the child packages enjoy full visibility of the private parts
of the parent. Yet, when the same package is moved outside of
the parent/child hierarchy, you enjoy the limited visibility you want,
but then you may not have the visibility to types and API's that you
might need.

[As a side note, I sometimes wonder if an enhancement to the Ada0Y
language might be to be able to specify a limited visibility of a
parent package's object's internals (a la not "protected" type in
C++). A protected class in C++ allows derived code to mess with the
internals, whereas normally the parent object's elements are a
black box. Use of limited visibility helps to reduce code coupling.]

I have found the object relationships are easier to define, and these
should perhaps be done first (perhaps initially as one package). After
this has been "purified/tested", then see how this can be broken down
into separate and perhaps "optional" packages and child packages.

Package visibility rules make the packaging more difficult, in my own
experience. Obviously if the project is huge, you'll want to define
the objects and package hierarchy up front (for sanity and quicker
development). It might also be stated that this is good practice
anyway, and should always be done this way.

-- 
Warren W. Gay VE3WWG
http://home.cogeco.ca/~ve3wwg





  reply	other threads:[~2003-07-26 15:27 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-26 13:08 Need advice re package organization Bobby D. Bryant
2003-07-26 14:25 ` Robert I. Eachus
2003-07-26 15:27   ` Warren W. Gay VE3WWG [this message]
2003-07-26 22:00     ` Robert I. Eachus
2003-07-27 22:01       ` chris
2003-07-28  2:53         ` Robert I. Eachus
2003-07-29  4:52           ` Richard Riehle
2003-07-27 22:02       ` Warren W. Gay VE3WWG
2003-07-28  8:38         ` Dmitry A. Kazakov
2003-07-29 17:18           ` Warren W. Gay VE3WWG
2003-07-30  8:42             ` Dmitry A. Kazakov
2003-07-30 21:00               ` Warren W. Gay VE3WWG
2003-07-30 22:46                 ` Randy Brukardt
2003-07-31 16:39                   ` Warren W. Gay VE3WWG
2003-07-31 17:31                     ` Randy Brukardt
2003-07-31 21:00                       ` Warren W. Gay VE3WWG
2003-07-31 22:13                     ` Robert I. Eachus
2003-08-01 12:51                       ` Warren W. Gay VE3WWG
2003-07-31  5:57                 ` Matthew Heaney
2003-07-31 16:57                   ` Warren W. Gay VE3WWG
2003-07-31 22:33                     ` Robert I. Eachus
2003-08-01  2:58                       ` Chad R. Meiners
2003-08-01 13:51                         ` Stephen Leake
2003-08-01 22:15                           ` Robert I. Eachus
2003-08-04 13:45                             ` Stephen Leake
2003-08-01 13:01                       ` Warren W. Gay VE3WWG
2003-07-31  9:04                 ` Dmitry A. Kazakov
2003-07-31 16:59                   ` Warren W. Gay VE3WWG
2003-07-31 20:41                     ` Randy Brukardt
2003-07-31 21:15                       ` Warren W. Gay VE3WWG
2003-08-01 20:04                         ` Randy Brukardt
2003-08-01 21:33                           ` Stephen Leake
2003-08-04 19:40                             ` Randy Brukardt
2003-08-04 19:52                               ` Stephen Leake
2003-08-05  3:36                   ` Richard Riehle
2003-08-05  4:03                     ` Hyman Rosen
2003-08-05  7:16                     ` Dmitry A. Kazakov
2003-07-26 17:03 ` Nick Roberts
replies disabled

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