Externalising an internal representation
Context
A system in which data is processed notionally in a number
of phases, where the phases are invoked by a driver program which itself is
easily modified. Phases are not currently well encapsulated, however: two
phases which are currently always consecutive share an internal data
representation which is adapted to the needs of those two specific phases,
not designed to be an interface format for arbitrary processing. There is a
requirement to add new (optional) phases which may intervene between two
phases which previously were always called consecutively. It is expected
that other new phases may be required in future.
Problem
Adding the new optional phases to the system as it stands
requires either that functionality of the existing phases be duplicated, or
that some optional phase use the ``internal'' format which was not designed
as an interface format. Either course will create maintenance problems
which are unacceptable in this context, given that there is an anticipated
need to add further phases in future.
Solution
Incrementally replace the internal format with an newly
defined and fully documented interface format, open to use by new phases.
Modify the existing first phases to output the new format optionally.
Develop the new optional phase using the new interface format as input. At
this point the original first phase outputs two formats depending on what
its successor will be. Next modify the old second phase to input the new
format, at which point the old format can be abandoned, and the ability of
the old first phase to output the old internal format can be removed. The
structure of the new system is now modular, with the driver program as a
Mediator\cite{GHJV}.
Consequences
The generation of an externally readable version of
the representation allows new modules to be attached with no further
alteration of the existing system, apart from the easily modifiable driver
program. This creates a more open system.
Depending on the nature and use of the old intermediate format, the new
system may possibly be slower than the old, since the interface format is
no longer so well adapted to the particular needs of the two originally
communicating phases. If speed is critical, this effect needs to be
considered in designing the new format and the altered phases.
Contributors
Rob Pooley, Perdita Stevens