|
Object Oriented COBOL I was recently
talking about OO COBOL with some friends and we came up with a number
of questions. By researching the net I was able to come up with
the following answers. You can think of this as a FAQ for OO
COBOL. What is an
object? An object is an item in the real world. You are an object and
so am I. Your pen, car, and TV are objects. Objects can also be
design entities in software design documents and implementation
entities in an application. What is a class?
Objects with common characteristics this could be in terms of
data or behavior or both. What is a method?
A piece of OO COBOL code. What types of
methods are there? In general there are class methods and instance
methods. How you call the
method: A class method is called by preceding the call with the name
of the class while an instance method is preceded with an
object reference to the instance of the class that has the method you
wish to invoke. How many copies
of the method there are at any given time (again, in practice in run
time implementation there is only one copy of code as in an XL
implementation but there can be 1 to N copies of the data associated
with a method). How do you tell the difference between a class method and an instance method when looking at code? The class methods will be inside of this section of code:
What new
vocabulary do I need to learn for OO COBOL that is different than
standard COBOL? self: a
reserved word that is defined as the object reference to the current
instance of this class. It is interchangeable with the real object
reference as a variable. super: a
reserved word that is defined as the object reference to the parent
class for this instance of a class. invoke: a
reserved verb that precedes the class or instance handle when making
OO method calls. Think of this as you might the CALL verb. We have already
covered the fact that you have a couple of new sections that delimit
the class and instance methods in a program. One other
paragraph heading that is very important and is the same for class
and instance sections is the Object-Storage Section. What is the
Object-Storage Section? In a class, an instance method is the data
that is global to the class or to all instances of a class. Again the
class section of the code has its own Object-Storage Section and the
Instance Method section of the code has its own Object-Storage
Section. That is the
basics of what you need to know to start looking at and eventually
coding OO COBOL. Its not all that bad: the syntax is pretty
easy, but thinking and designing code in terms of objects is what is
going to be the hurdle. If you have been writing modular code for a
while, then the hurdle may not be too great. I would like to
recommend a book that seems to be pretty recent and covers OO COBOL
nicely, An Introduction to Object Cobol by E. Reed Doke
and Bill C. Hardgrave.
Copyright The 3000 NewsWire. All rights reserved. |