A Computer Program Structure that Allows for Easier Maintenance

by Ed Perley

Consider how the operation of a complex industrial machine differs
from that of a computer program. First of all, the machine has one or
more control panels that give an up to the minute picture of what the
machine is doing. If something goes wrong, a trained technician can spot
the problem. Usually he can fix it by changing settings on the
control panel. Or, if a component fails, he can either plug in a new one
or switch to another one. Since all of the sockets have specific shapes,
there is no danger of plugging a component in the wrong socket. Usually,
all corrections can be made without turning the machine off or by spending
hours examining diagrams of the machine's components.

It occured to me that it should be possible to design computer
programs that have the above mentioned features. Some of my ideas
are discussed below. There are three distinct parts to this system
of programming, which are described below.

Use of temporary global variables * to pass values to and from functions.

Use of a function control panel to monitor and control all
function calls.

Use of a logic control panel to monitor and control program logic.

Using Temporary Global Variables to pass values to Modules

Temporary global variables are used to pass information to and
from program functions or modules. They consist of global arrays of variables,
one for each data type that the program will need to use. In languages
that use pointers, there can also be an array of pointers.
The names of these variables would be standard, ie. all programs with this type
of design would use these same variables.

If properly implemented, this system could minimize errors
resulting from mismatched varible types and confusion about whether
variables need to be local or global. These properties also will
make it easier to use a module in other programs with no modification.

The rules for a given program function or module are given below.

As much as is possible, all variables within a module will be
local.

Variables needed by a module are placed in the appropriate temproary
global variables, as specified by documentation, before the module is
called.

Before it does anything else, the module will copy these values
to local variables within the module, and zero out the global
variables.

If a type mismatch is detected, or the information read in is
invalid, the module will return an error code and exit.

After performing its assigned task, the module will copy its
output to global variables. One variable will receive a status
code that will indicate if the module operated correctly. It will
also indicate if any output is outside the range of outputs
expected.

The module will contain text that specifies which global
variables it will read and which ones will receive its output.
These will be displayed by the the control panel, which is described
below.

The code that calls the module will copy the information to it's
local variables, and zero out the temporary global variables, making them ready
for reuse.

The Control Module and Control Panel

The control module and control panel control all calls to functions
and modules in a program.

Every module and function in the program is assigned a number.
No program module is called directly. Instead, the appropriate
number is placed in a temporary integer variable, and the control module
is called. All calls for functions and program modules are made
through the control module. This system could conceivably be extended
to call separate programs if there is a means to pass variables to
them.

The Control Panel is a screen display of all of the
modules that are called in the program. It can be used to turn
a module off or on, or to substitute a different module to do the required
task. And this can be done while the program is running. It will
also display basic documentation for each module, saying what is
it's purpose, what modules it calls, and what global variables it needs to
read and write to. It will also display a status code for each module.

On the Programming Menu (Link is shown below) is a link to my
report on the design of a Surface View program, using a program
structure similar to this one.

The Logic module and Logic Control Panel

The logic module will control any program logic that may need to
be modified when the program needs to debugged or upgraded. Like the
control module above, it will have its own control panel. It will
use a system something like my discussion on logic tables (Use the
link to the Programming Menu below.)

There will be future discussion on this design in the future. I have been
advised that there are some problems with this plan that should
be addressed.

* I changed the term standard global variables to temporary global variables.
I like it better.