
line r. There are certain restrictions in the way that these
routines may be called; if these restrictions are violated
the routines "trap" to an error-handling subroutine
which is to be provided by the users of the routine.
Additional routines are available which reveal to the
caller the number of words in any line, the number of
lines currently stored, and the number of characters in
any word. Functions DELINE and DELWRD are
provided to delete portions of lines which have already
been stored. A precise specification of a similar module
has been given in [3] and [8] and we will not repeat it
here.
Module 2: INPUT. This module reads the original
lines from the input media and calls the line storage
module to have them stored internally.
Module 3: Circular Shifter. The principal functions
provided by this module are analogs of functions pro-
vided in module I. The module creates the impres-
sion that we have created a line holder containing
not all of the lines but all of the circular shifts of the
lines. Thus the function call CSCHAR(I,w,c) provides
the value representing the cth character in the wth
word of the lth circular shift. It is specified that (1)
if i < j then the shifts of line i precede the shifts of line
j, and (2) for each line the first shift is the original
line, the second shift is obtained by making a one-word
rotation to the first shift, etc. A function CSSETUP is
provided which must be called before the other functions
have their specified values. For a more precise specifica-
tion of such a module see [8].
Module 4: Alphabetizer. This module consists
principally of two functions. One, ALPH, must be
called before the other will have a defined value. The
second, ITH, will serve as an index. ITH(i) will give the
index of the circular shift which comes ith in the
alphabetical ordering. Formal definitions of these
functions are given [8].
Module 5: Output. This module will give the desired
printing of set of lines or circular shifts.
Module 6: Master Control. Similar in function to the
modularization above.
Comparison of the Two Modularizations
General. Both schemes will work. The first is quite
conventional; the second has been used successfully in
a class project [7]. Both will reduce the programming to
the relatively independent programming of a number of
small, manageable, programs.
Note first that the two decompositions may share
all data representations and access methods. Our
discussion is about two different ways of cutting up
what may be the same object. A system built according
to decomposition 1 could conceivably be identical
after assembly to one built according to decomposition
2. The differences between the two alternatives are in
the way that they are divided into the work assignments,
and the interfaces between modules. The algorithms
used in both cases might be identical. The systems are
substantially different even if identical in the runnable
representation. This is possible because the runnable
representation need only be used for running; other
representations are used for changing, documenting,
understanding, etc. The two systems will not be identical
in those other representations.
Changeability. There are a number of design de-
cisions which are questionable and likely to change
under many circumstances. This is a partial list.
1. Input format.
2. The decision to have all lines stored in core. For
large jobs it may prove inconvenient or impractical to
keep all of the lines in core at any one time.
3. The decision to pack the characters four to a word.
In cases where we are working with small amounts of
data it may prove undesirable to pack the characters;
time will be saved by a character per word layout. In
other cases we may pack, but in different formats.
4. The decision to make an index for the circular'
shifts rather that actually store them as such. Again, for
a small index or a large core, writing them out may be
the preferable approach. Alternatively, we may choose
to prepare nothing during CSSETUP. All computation
could be done during the calls on the other functions
such as CSCHAR.
5. The decision to alphabetize the list once, rather
than either (a) search for each item when needed, or
(b) partially alphabetize as is done in Hoare's rIND
[2]. In a number of circumstances it would be advan-
tageous to distribute the computation involved in
alphabetization over the time required to produce the
index.
By looking at these changes we can see the differences
between the two modularizations. The first change is
confined to one module in both decompositions. For the
first decomposition the second change would result in
changes in every module! The same is true of the third
change. In the first decomposition the format of the
line storage in core must be used by all of the programs.
In the second decomposition the story is entirely
different. Knowledge of the exact way that the lines are
stored is entirely hidden from all but module 1. Any
change in the manner of storage can be confined to that
module!
In some versions of this system there was an addi-
tional module in the decomposition. A symbol table
module (as specified in [3]) was used within the line
storage module. This fact was completely invisible to
the rest of the system.
The fourth change is confined to the circular shift
module in the second decomposition, but in the first
decomposition the alphabetizer and the output routines
will also know of the change.
The fifth change will also prove difficult in the first
decomposition. The output module will expect the index
to have been completed before it began. The alpha-
betizer module in the second decomposition was
1055
Communications December 1972
of Volume 15
the ACM Number 12