comp.lang.ada
 help / color / mirror / Atom feed
* Re: Use of "is separate" and compilatio
@ 1989-11-27 20:29 stt
  1989-11-28 17:40 ` Ed Matthews
  1989-11-29 20:16 ` arny.b.engelson
  0 siblings, 2 replies; 8+ messages in thread
From: stt @ 1989-11-27 20:29 UTC (permalink / raw)



We have built a number of very large Ada systems at Intermetrics,
and our customers have built some even bigger ones.
As a result of this we have built up a very strong
prejudice *against* the use of subunits (aka "is separates").
Instead, we try to structure our system as a series
of medium size packages (about 500-2500 lines each),
using either a functional or object-oriented structuring.

Ideally, each of these packages represents a well-defined,
relatively self-contained component of the system.
When making a change or trying to understand a particular
feature of the system, it is generally only necessary to
look at the single medium-size package which implements it.
Furthermore, most of the candidates for low-level, small-chunk-of-code
reuse, are within a single package.

Subunits foul up this structure in a number of ways:
First and foremost, a single subunit is in no way "self-contained."
It has unlimited visibility into its parent unit, representing
a very "broad" interface (the worst kind).

Secondly, when editing a subunit, other related code is
not immediately available, so we have found that programmers
working on a heavily "subunited" program tend to reinvent the
wheel repeatedly, rather than noticing a similar sequence
of code in another subprogram of the same package, and
separating off that logic as a local shared subprogram
of the package.

Thirdly, subunits cause havoc with sophisticated optimizers,
especially subunits within subprograms.  When calling a separately-compiled
subunit the compiler must assume the worst: that the subunit
accesses and/or updates all objects it can see, meaning that
all local variables visible to the subunit must be stored back
into memory from registers before the call, and reloaded afterward.

Finally, they tend to allow single library units to grow
without bound.  Often when a subsystem grows too big, it
is wise to split it up into a number of packages, each with
a narrower purpose.  When using subunits, the tendency
is to instead just keep adding more and more functionality
into a single package.

As far as recompilation, subunits are also bad news, since
almost all compilers will recompile *all* subunits when
any change is made to the enclosing parent unit, including
just the addition of another subunit.  Of course, the total
amount of code is no greater than if the package had not
been "subunited" (presuming you resisted the growth-without-bound
phenomenon), but most compilers will compile a single 2500-line
package much faster than 50 50-line subunits.
Of course you win when the only change to be made was in a single
subunit, but in our experience, that incentive causes many
of the problems with subunits -- the avoidance of restructuring
of the package.  Many bugs can best be fixed by modest
restructuring of the implementation of a package.  
Any attempt at restructuring in the presence of subunits
causes them all to be recompiled again.

I should mention that reasonable people differ
on this whole "subunit" issue, and there are
selected places where a subunit can be extremely useful,
to, for instance, isolate a very small bit of host-dependent
code.  However, on balance, I would regard them almost
as bad as a goto -- to be used only when all other 
avenues have been exhausted.

As Lori Clarke, et al, said in their classic critique of
Ada subunits long ago, "nesting in Ada is for the birds."

S. Tucker Taft
Intermetrics, Inc.
Cambridge, MA  02138

^ permalink raw reply	[flat|nested] 8+ messages in thread
* Re: Use of "is separate" and compilatio
@ 1989-11-29 17:43 stt
  0 siblings, 0 replies; 8+ messages in thread
From: stt @ 1989-11-29 17:43 UTC (permalink / raw)



Ed Matthews (edm@verdix.com) points out that fancy editors
can improve the situation w.r.t. subunits:
> 
> . . . With modern
> editor technology and windowing, the entirety of a package, whether it
> be one package of 2500 lines, or 25 subunits of 100 lines, can be 
> easily viewed.  Further, in editors with syntactic and semantic
> navigation, understanding a unit is equally easy no matter how the
> program is structured.
> 
I can't argue with this since I haven't got one of these fancy editors!
("Tags" with vi helps a little, but has real trouble with overloading
and the multi-level namespace.)

In any case, even though I do have a multi-window workstation on my desk,
I still find I like to look at good old hard-copy listings
now and then, and hyper-text just hasn't arrived on our line printer
(nor even our laser printer!) yet.  Lots of subunits make any
kind of paper and pencil work a royal pain.

S. Tucker Taft
Intermetrics, Inc.
Cambridge, MA  02138

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~1989-12-07 23:32 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1989-11-27 20:29 Use of "is separate" and compilatio stt
1989-11-28 17:40 ` Ed Matthews
1989-11-29 20:16 ` arny.b.engelson
1989-12-01 18:29   ` Leonard Vanek
1989-12-04 16:52     ` Michael Schwartz
1989-12-06 12:54       ` Mike Walsh
1989-12-07 23:32     ` Fred Stluka
  -- strict thread matches above, loose matches on Subject: below --
1989-11-29 17:43 stt

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