Managing source code real estate is a wide concept that can
cover very different things, ranging from making the source
code compliant to defined coding standards, to plain migrations.
In all cases, quality is of course a major concern.
A simple word, and quite a popular topic, quality is often a
subjective matter. Organisations tend to find it difficult to define
precisely what is really meant by quality, but they will surely
agree on one thing though: a good quality source code should be
easily readable and maintainable. And that is what this newsletter
is all about: achieving a sufficient level of readability and
facilitating maintenance using RainCode.
The following case study is about an extreme case of quality
improvement in automatically generated COBOL code.
Case Study
VisualAge Pacbase is a fourth generation language, marketed and
supported by Big Blue (IBM). One interesting characteristic of
this environment language lies in its intermediate COBOL code
generation for compilation purposes.
This property opens a possible migration path for organizations
that wish to move away from PACBASE, such as DVV.
DVV Insurance is one of the leading insurance companies in Belgium
and part of Dexia, Belgium's second largest financial group.
The consolidated premium income of DVV in 2001 amounted to EUR 927
million. DVV offers a full range of insurance, savings and investment
products and more than ever emphasizes on satisfying customers by
means of an effective distribution strategy that meets their needs.
DVV's well developed multi-channel distribution system is based on an
exclusive agents' network, bankinsurance with banks of the Dexia
group, brokerage via Belstar and Luxstar, direct writing through
CoronaDirect and sectoral pensions with Sepia.
DVV has several applications, represented by thousands of programs,
all written in Pacbase. DVV would like to leave the Pacbase world.
They have in fact two alternative ways out:
Either re-write the whole application park in another
programming language; a solution that will be very expensive
and error-prone.
Start with the generated COBOL code. As it was never generated
with maintenance or migration in mind, the generated code is
unreadable, unstructured and excessively verbose. It would be
totally unreasonable to consider maintaining this generated
code directly.
The Renovation process
Our approach is to opt for the second alternative; but to renovate
the generated code systematically through the application of automatic
improvements. The re-structuring of the code is done by applying a
sequence of passes on the source, among which:
Cosmetic enhancements such as: systematic indentation,
adding the optional reserved words (THEN, END-IF, etc.).
Removal of dead components.
Replacing complicated loops by natural constructs.
Replacing GO TO's by equivalent, but structured constructs.
Replacing sequences of IF's by EVALUATE statements.
Each step can take advantage of the result of the other steps,
incrementally rising the abstraction level of the code.
This method proves to be advantageous in many ways.
Executability is guaranteed. The risk of error is quite low.
If an error were made, it would be infinitely repeated through
the automatic process, which means that the probability of not
catching it is close to null.
Semantic equivalence between the initial code and the renovated
code is guaranteed.
The process can be applied at will, even after potential
manual changes were made; improvements can be made
incrementally.
As variable names, labels and even comments are retained from
the original PACBASE programs, the programmers who were familiar
with the old system can maintain the migrated system
proficiently.
There is no eclipse effect: the program continues to run
during the renovation process, and can be tested at any time.
Some Results
To give you an idea of what RainCode was able to accomplish on
the first application we renovated (about 600 programs), we recorded
the following statistics:
For 49% of the programs, all the GOTOs were removed.
For more than 92% of the programs, less than 15% of GOTOs are
remaining.
We typically reduce the size of a program to 60-90% of its
original size, in terms of number of statements.
The resulting reshaped sources are equivalent to the Pacbase sources
in terms of functionality and semantics; they are shorter, better
structured and way more readable.
That's all folks !!!
In our next newsletter, we will expose the new developments of Ride,
a RainCode based development environment that allows you to write
and execute your RainCode scripts in a user-friendly interface.