Change Management
Designing for Maintenance
Reusability
Reusability is a property of a code module such that the module can be used, as is, by several applications. In designing for reuse, the goal is to identify modules for potential reuse. The two most popular methods of implementing code reuse are program templates and reusable modules.
Program templates consist of standard code that performs a simple function. For instance, there are three basic types of business programs: report, edit/ validate, and file update. For a report, there are standard sections for reading file data, formatting
the data, and writing the report (see Figure 18-1). Reading and writing can be standardized regardless of the data definition for input. The formatting of data must be customized. In writing the report, there are sections of code for beginning-of-page,
body-of-page, and end-of-page. There may be sections for beginning-of-report and end-of-report, too. The report program might or might not have an internal sort routine that changes the sequence of the input file.
Templates can be developed to describe the 12 or so most common variants of the three basic types of programs. For instance, a report program is developed with and without sorts. COBOL or some other procedural language is used to define the standard versions
and the only items left to the application programmer are procedures specific to the application.
The templates are stored as read only modules in a library. When a new use is defined, the module to be used is copied and given a new name. The newly named module is then modified and customized for its current use.
The advantage of a template is that a finite number of variations are developed and then are modified as needed for a specific use. There is little or no maintenance on the templates once they are developed, and only a few new templates per year would
ever be developed. The number of support staff could be close to zero.
A template is a partial program that is completed for a particular application. A reusable module is a small, single function, well-defined, and standardized program module that can be used as a called routine, or as a copy book in COBOL. For instance, a date edit routine might be developed as a reusable module (see Figure 18-2).
When a reusable module is desired, a library of reusable modules is studied to determine which ones fit the application's needs. For reusable modules that do fit an application, the individual module code is examined to verify that it performs as required. Then the module is called at the appropriate place in the application's processing.
Each application team determines which modules it might have that could be reused in its own or in other applications. Then the modules are singled out for special development as independent routines. The finished module is quality assurance tested by
the librarians to ensure that it performs as documented. The librarian is an expert in reusable standards, quality assurance testing, and code management techniques. Eventually, the code is stored in a reusable library whose contents are published
for application developers' use.
Publication of reusable library contents can be awkward. Paper might be too voluminous to be useful or cost-effective. Electronic publication requires indices to assist users in identifying potential modules for their use. The indices might include keywords to describe function, language, date of development, type of input, and so on. If indices are not coded to capture the essential characteristics of the modules, they are useless.
The amount of organizational support required to maintain reusable libraries has been the major impediment to reusable library adoption in most industries. Librarians test, store, and maintain references to the modules in the reusable library. A large number of modules, for instance over 1,000, makes maintenance of the library integrity and accuracy a major task. Locating modules for use is also a major task. Librarians become specialized in performing these functions. Without proper organizational support, reusable libraries soon become unused and useless.
The arguments for reuse are substantial. As much as 75% of all code on a typical business application is redundant, and therefore, a candidate for reuse. Database descriptions, program procedure templates, and individual modules are all candidates for
reuse that can save companies time and money in application development. The more reused code, the less extensive the custom code developed, the less extensive the testing required, and the less the cost of the application.
Identification Division. Program-1 D. ABCVIDADD. Environment Division. Configuration Section. Source-Computer. IBM-3080. Object-Computer. IBM-3080. File Section. Select Input-File from UR-D0001 as RPTIN. Select Report-File from UR-P001 as RPTOUT. File Division. Input Section. FD Input-File Block contains 100 records. Record contains 400 characters. 01 Input-File-Record Pic x(400). FD Report-File Block contains 1 record. Record contains 132 characters. 01 Report-File-Record Pic x(132). Working-Storage Division. 01 Miscellaneous-counters. 05 Page-Count Pic 99 value zero. 05 Line-Count Pic 99 value zero. 05 Input-record-count Pic 9(7) value zero. 05 Output-record-count Pic 9(7) value zero. 05 End-of-file-marker Pic 9 value zero. 88 End-of-file value 1. 88 Not-end-ot-file value 0. ******** 01 Copy Input-File-Description statement goes here. ******** 01 Report-Headers. 05 Header-01. 10 Filler pic x(45) Value spaces. 10 H1 pic x(23) value ‘Company Standard Header’. 10 Filler pic x(15) value spaces. 10 Date pic x(8) value spaces. 05 Header-2. 10 Filler pic x(45) Value spaces. 10 H1 pic x(23) value 'Report Standard Header'''. 10 Filler pic x(15) value spaces. 10 Time 15 Hour pic xx value spaces. 15 Filler pic x value 15 Hour pic xx value spaces. 15 Filler pic x value 15 Hour pic xx value spaces. |
FIGURE 19-1 Partial COBOL Program Template for a Report
Linkage Section. 01 In-Date. 05 In-Date-Month pic xx. 05 In-Date-Day pic XX. 05 In-Date-Year pic XX. 01 Errors. 05 Err-table occurs x times. 10 Err pic 9 comp. Procedure Division. Link. Enter linkage. Entry Link-date-edit using in-date, errors Enter COBOL. Initialize. Move zeros to Errs. Check-Numencs If In-Date-Mo not numeric move 1 to err(1). If In-Date-Day not numeric move 1 to err(2). If In-Date-Year not numeric move 1 to err(3). If err(1 ) - 1 or err(2) = 1 or err (3) = 1 go to End-Test Check-values If In-Date-Day > 0 continue else move 1 to err(4). If In-Date-Year > 1992 and In-Date-Year < 2015 continue |
FIGURE 18-2 Reusable COBOL Module for Date Edit