TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy


Options: Use Classic View

Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Topic: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Mike Brenner <[log in to unmask]>
Tue, 14 Apr 1998 08:30:41 -0400
text/plain (72 lines)
Bob Eachus > ... [No] more than 6 withs on a package spec,
           > or 15 on a package body ...

Here is another statistic. To add it up carefully, you must not
just grep on the word with. You must filter out comments nad
quoted string and variable containing the word with as a substring.

There was another thing to filter out: withs that were temporarily
commented out. I uncommented 5 withs for this count, because they
are uncommented for certain ports, since Ada does not have
conditional compilation.

The lines of code (LOC) was counted as uncommented, unquoted

Dividing the release files (which each contain many units) into
individual files for grep counting was done with gnatchop. That
means that the subunits and units are grouped together. There were
36 subunits (recognized by IS SEPARATE). Their withs were not
broken out separately, because that would have taken a few minutes.

Project: MIMS (version emcc0153)

  239 ADS files     133 ADS files with withs    229 withs
  501 ADB files     435 ADB files with withs   1526 withs
     59,580 LOC     568 files with withs       1755 withs

Average withs per ADS: 1
Average withs per ADS with withs: 2
Average withs per ADB: 3
Average withs per ADB with withs: 4
Maximum number of withs: 48

This accidentally agrees with Bob Eachus' standard of not having
to many withs. The 48 withs were on a test program importing a lot
of stuff to test. The hardest things to read and to maintain are
the device-independent nested withs. Since Ada does not have
conditional compilation (an IF statement that can select
package bodies), there have to be multiple levels of nesting
in order to make device drivers pluggable.

These pluggability packages only have about 6 withs per package.
So, Bob's standard is not an accurate predictor of where the
hard parts are in this particular piece of code.

Also, this code contains many classes per package. If somebody
were to use this again in the DOD with a 100 lines per package MAXIMUM
then there would be many more packages, and there would be
correspondingly more withs.

In particular, in the highly nested elaboration circles of the
pluggable device drivers, a class-per-package policy would require
approximately two dozen withs per package for the most complex
packages. To make this program elaborate under the austere gnat
rules of gnat 2.07, the number of elaboration levels had to be
reduced significantly, a lot of pure packages had to be spun off
and identified as pure, and a lot of self-tests had to be put
into separate packages or not be run upon elaboration.

The predictors of these problems would be the percentage of pure
packages (aiming for about 25 percent of the project),
the number of levels deep of the withs, the number of package
bodies crossing withs (each withs the other's ancestor visible part),
and the maximum depth of the withing tree.

However, the numbers do match Bob's standard on this well-designed
project. I am just not sure why yet.

Mike Brenner