Java Reference
In-Depth Information
DISPLAY "MSG SIZE equals," MSG-SIZE.
EXIT-PROGRAM.
EXIT PROGRAM.
STOP RUN.
Let's examine these two programs from an object-oriented perspective, using
the terminology of the object-oriented design methodology.
You can consider the subroutine MYSUB a class. That is, every time MYSUB is
called—even if it is called from different programs—it will behave the same way.
Any features, or logic, that MYSUB has will be available to all calling programs. At
the same time, some parts of MYSUB are not available to the outside world. For ex-
ample, any variables in MYSUB's WORKING-STORAGE are private to MYSUB.
And the details of MYSUB's logic are not known to any calling programs; only its
interface (or LINKAGE SECTION) is published.
You can consider any instance of the parameter item MYSUB-CONTROL in a
calling program as an object after MYSUB has been called. That is, after MYSUB
has performed its logic (at the request of a calling program), the result of that logic
is available in MYSUB-CONTROL.
A calling program can examine or modify the contents of items in MYSUB-CON-
TROL (MSG-TEXT or MSG-SIZE) and perform some logic based on those contents.
These items are called class data members, or properties in OO terminology.
Another program in the COBOL run unit can call MYSUB, with its own
MYSUB-CONTROL (parameter), and evaluate the result. In this case, CALLER #1's
copy of MYSUB-CONTROL will, of course, not be affected by CALLER #2. Each in-
stance of a MYSUB-CONTROL area will now contain unique information. In this
case, the unique MYSUB-CONTROL areas are objects. In fact, a single program can
manage two separate MYSUB-CONTROL(s) as long as they have unique names.
CALLER COBOL: CONTROL
Suppose you've defined CONTROL areas for two subroutines as follows:
IDENTIFICATION DIVISION.
PROGRAM-ID. CALLER.
DATA DIVISION.
WORKING-STORAGE SECTION.
* Create one set of parameter definitions.
01 MYSUB1-CONTROL.
03 MSG-TEXT PIC X(20).
03 MSG-SIZE PIC 9(8).
*
Create a second set of parameter definitions.
Search WWH ::




Custom Search