comp.lang.ada
 help / color / mirror / Atom feed
From: george@gentoo.org
Subject: Re: parent package referring to child
Date: Thu, 11 Oct 2007 02:45:36 -0700
Date: 2007-10-11T02:45:36-07:00	[thread overview]
Message-ID: <1192095936.309410.62410@k79g2000hse.googlegroups.com> (raw)
In-Reply-To: <1191997397.865251.322480@d55g2000hsg.googlegroups.com>

eliben wrote:
> I have a package FOO that encapsulates a large part of the system. Now
[..]
> Is there any way to overcome this problem ? Perhaps a different design
> that suits the requirement and doesn't go against the Ada standard ?
I have been faced with just such a problem, when writing a library to
access abf files (a special data format used by the most common
software in electrophysiology). I needed to define a record type with
near a thousand fields (beat you here ;)) and did not want to put it
all into the single spec. My solutions was exactly redesign, or rather
I designed it from ground up to be appropriately split between the
parent and child modules.

On top there was ABF with the most common (elementary) types. Then
there were children. ABF.Header to keep the big struct and IO ops
specific to the header part. ABF.Data, ABF.Synth, etc (some with
further children) for dealing with the corresponding parts of data
file (it can have one of a few modes each of which imposed a somewhat
different layout of the data). All children would naturally see ABF
and most would with the ABF.Header, as necessary. In the further
development (this one not finished actually) I even split that big
struct off into a private child with the intention of creating a
somewhat "thicker" "binding" (to the data layout).

You may try playing with Ada-2005 features, as others suggested, but
that seems to require making the corresponding type tagged. Plus, in
the long run and for a non-trivial problem, it may be well worth
splitting or designing the split early in the process. Of course it is
up to you to know best, what is the appropriate way (for example, if
the overall structure of the project is expected to be plain and not
extensible it may be better to try to make limited with do what you
need instead).

George




  parent reply	other threads:[~2007-10-11  9:45 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-10  6:23 parent package referring to child eliben
2007-10-10  9:07 ` Georg Bauhaus
2007-10-10  9:24   ` eliben
2007-10-10 14:46     ` Adam Beneschan
2007-10-10 19:26   ` Simon Wright
2007-10-10 14:59 ` Matthew Heaney
2007-10-10 18:54   ` Vadim Godunko
2007-10-10 19:32     ` Matthew Heaney
2007-10-10 20:20       ` Adam Beneschan
2007-10-11  4:12         ` Randy Brukardt
2007-10-11 15:21           ` Adam Beneschan
2007-10-19 12:45           ` Vadim Godunko
2007-10-10 19:51   ` Matthew Heaney
2007-10-10 17:06 ` Jeffrey R. Carter
2007-10-10 19:17 ` anon
2007-10-11  9:45 ` george [this message]
2007-10-12  4:15   ` Jeffrey R. Carter
2007-10-12  9:51     ` Georg Bauhaus
replies disabled

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