Writing object-oriented programs
When you write an object-oriented (OO) program, you have to determine what classes you need and the methods and data that the classes need to do their work.
About this task
OO programs are based on objects (entities that encapsulate state and behavior) and their classes, methods, and data. A class is a template that defines the state and the capabilities of an object. Usually a program creates and works with multiple object instances (or simply, instances) of a class, that is, multiple objects that are members of that class. The state of each instance is stored in data known as instance data, and the capabilities of each instance are called instance methods. A class can define data that is shared by all instances of the class, known as factory or static data, and methods that are supported independently of any object instance, known as factory or static methods.
Using COBOL for AIX, you can:
- Define classes, with methods and data implemented in COBOL.
- Create instances of Java™ and COBOL classes.
- Invoke methods on Java and COBOL objects.
- Write classes that inherit from Java classes or other COBOL classes.
- Define and invoke overloaded methods.
In COBOL for AIX programs, you can call the services provided by the Java Native Interface (JNI) to obtain Java-oriented capabilities in addition to the basic OO capabilities available directly in the COBOL language.
In COBOL for AIX classes, you can code CALL statements
to interface with procedural COBOL programs. Thus COBOL class definition
syntax can be especially useful for writing wrapper classes
for procedural COBOL logic, enabling existing COBOL code to be accessed
from Java.
Java code can create instances of COBOL classes, invoke methods of these classes, and can extend COBOL classes.
Restrictions:
- COBOL class definitions and methods cannot contain
EXEC SQLstatements and cannot be compiled using theSQLcompiler option. - COBOL programs that use object-oriented syntax for Java interoperability cannot
contain
EXEC CICSstatements, and cannot be run in CICS®. They cannot be compiled using theCICScompiler option.