© 2015 Starsoft. All Rights Reserved.
Welcome to this short introduction to Object Oriented Cobol.
Let’s start off by acknowledging the person who led the way.
© 2015 Starsoft. All Rights Reserved.
There are over 400 warships in the US Navy…
Only two of them are named in honor of a woman
One of them is named the USS Hopper
© 2015 Starsoft. All Rights Reserved.
The NERSC (National Energy Research Scientific Computing Center) first
Cray XE6 petaflop supercomputer is named Hopper
© 2015 Starsoft. All Rights Reserved.
Rear Admiral Grace Murray Hopper
(December 9, 1906 – January 1, 1992)
She was a champion
for increasing the
usability of computers,
understanding that
their power and reach
would be limited
unless they were made
to be more user
friendly.
Grace Hopper, was a
pioneer in the field of
software development and
programming languages
and the creator of the first
compiler.
© 2015 Starsoft. All Rights Reserved.
2002 – ISO COBOL-2002 (OOC)
1959 – Short Range Committee - COBOL-60
1968 – American National Standards Institute – ANSI COBOL-68
1974 – ANSI COBOL-74
1985 – ANSI COBOL-85
1997 – ISO (Committee Draft) Draft – Object Oriented Cobol
Grace Hopper pioneered the implementation of standards for computer systems
© 2015 Starsoft. All Rights Reserved.
From the ISO 2002 Cobol standard
© 2015 Starsoft. All Rights Reserved.
a
compute a = b + c
b c
Cobol program - A simple program
Entry point
Variables
Procedure
Program
One program entry point
One common memory
© 2015 Starsoft. All Rights Reserved.
Cobol program – Multi-procedural
One program entry point
One common memory for all procedures
a
compute a = b + c
b c d
compute d = e + f
e f
Entry point 1 Procedure 1 Procedure n Entry point n
Variables pnVariables p1
Program
© 2015 Starsoft. All Rights Reserved.
a
compute a = b + c
b c d
compute d = e + f
e f
The analogy in Object Oriented Cobol
Entry point 1 Procedure 1 Procedure n
Each procedure has its own entry point
Each procedure has its own memory
Each procedure is invoked individually
Entry point n
Variables pnVariables p1
Program
© 2015 Starsoft. All Rights Reserved.
Variables p1
a
compute a = b + c
b c d
compute d = e + f
e f
The OO-Cobol Class
Entry point 1 Method 1 Method n Entry point n
Variables pn
In Object Oriented Cobol, as in Java –
o a procedure is called “method”
o methods are defined in a “Class”
Class
© 2015 Starsoft. All Rights Reserved.
OO-Cobol – Class
Write the Cobol source that defines the Class
a
compute a = b + c
b c
Method
Method
Variables
Class
© 2015 Starsoft. All Rights Reserved.
OO-Cobol – Program invokes Class
Write the Cobol source of the Program that will use the Class
a
compute a = b + c
b c
Method
Method
Variables
Class
invoke method…
Program
Declare a reference to the Class in the program
The program can then invoke methods of the Class
© 2015 Starsoft. All Rights Reserved.
For example
a
compute a = b + c
b c
Method
“COMPUTE_SALARY”
Method Variables
NAME
ID
DAILY_SALARY
Class
“Employee”
invoke method
COMPUTE_SALARY
Program
EMP_CALC
OO-Cobol – Program invokes Class
© 2015 Starsoft. All Rights Reserved.
Class Definition
Class Variables
OO-Cobol – Defining a Class
© 2015 Starsoft. All Rights Reserved.
Method – “new”
OO-Cobol – Class Methods
Just like a cookie cutter is used to create cookies, the Class serves as a
template for creating a live instance of itself – an object.
The “new” method creates the object that will be used by the program.
© 2015 Starsoft. All Rights Reserved.
Method – “new”
OO-Cobol – Class Methods
The “new” method giving us access to an object is similar to turning the
ignition key in a car – once we do so, we can use the functions that the car
has to offer: driving, braking, honking and so on.
© 2015 Starsoft. All Rights Reserved.
Method - Compute
Method – Set
OO-Cobol – Examples of other Class Methods
© 2015 Starsoft. All Rights Reserved.
Declaring the Class in the invoking program is analogous to
declaring a file in the INPUT-OUTPUT section
OO-Cobol – Referencing the Class
© 2015 Starsoft. All Rights Reserved.
Defining the object to be used in the invoking program is analogous
to defining the file record in the FILE section
OO-Cobol – Defining the object
© 2015 Starsoft. All Rights Reserved.
OO-Cobol – Example of invoking the “new” method
© 2015 Starsoft. All Rights Reserved.
OO-Cobol – Example of invoking the “GET_NAME” method
© 2015 Starsoft. All Rights Reserved.
OO-Cobol – Objects
Like putting a “new” coin in a slot machine “returns” a new ball to play with
each time, the program can work with a number of objects at the same time.
© 2015 Starsoft. All Rights Reserved.
OO-Cobol – OO implementation
Encapsulation
Restricting access to an Object’s components
For example – Using method variables instead of global WORKING-STORAGE
Creating a sub-type of a Class while reusing its code and memory definition
Example – Defining a Class for computing salaries for Employees and Managers
Polymorphism
Inheritance
Invoking the same method name in different objects, different parameters
Example – “CALCULATE_SALARY” for both Manager and Employee
© 2015 Starsoft. All Rights Reserved.
Class Definition - Inherits
Class Variables
OO-Cobol - Inheritance
© 2015 Starsoft. All Rights Reserved.
Method – “new”
OO-Cobol - Inheritance
© 2015 Starsoft. All Rights Reserved.
Method Override – COMPUTE_SALARY
OO-Cobol - Inheritance
© 2015 Starsoft. All Rights Reserved.
OO-Cobol – Java integration
Using Java Class String in an OO-Cobol program
© 2015 Starsoft. All Rights Reserved.
OO-Cobol – Java integration
Using JSON object
© 2015 Starsoft. All Rights Reserved.
OO-Cobol – Java integration
Send/Receive JSON data via Ajax with AngularJS client
Use hashmaps to store data
Define and use Java arrays (OCCURS DYNAMIC)
Define and use Java variable types such as String (PIC X ANY LENGTH)
Run as servlet under webserver using HTTP session
Monitor performance using standard Java performance tools
These are just a few of the possibilities that open up for you when you by
using Object Oriented Cobol – getting the best of both worlds
© 2015 Starsoft. All Rights Reserved.
Thank you.
And one final word about Grace Hopper…
© 2015 Starsoft. All Rights Reserved.
While she was working on a Mark II Computer at Harvard University in 1947, her
associates discovered a moth stuck in a relay and thereby impeding operation,
whereupon she remarked that they were "debugging" the system.
The remains of the moth can be found in the group's log book at the Smithsonian
Institution's National Museum of American History in Washington, D.C.

Object Oriented Cobol

  • 1.
    © 2015 Starsoft.All Rights Reserved. Welcome to this short introduction to Object Oriented Cobol. Let’s start off by acknowledging the person who led the way.
  • 2.
    © 2015 Starsoft.All Rights Reserved. There are over 400 warships in the US Navy… Only two of them are named in honor of a woman One of them is named the USS Hopper
  • 3.
    © 2015 Starsoft.All Rights Reserved. The NERSC (National Energy Research Scientific Computing Center) first Cray XE6 petaflop supercomputer is named Hopper
  • 4.
    © 2015 Starsoft.All Rights Reserved. Rear Admiral Grace Murray Hopper (December 9, 1906 – January 1, 1992) She was a champion for increasing the usability of computers, understanding that their power and reach would be limited unless they were made to be more user friendly. Grace Hopper, was a pioneer in the field of software development and programming languages and the creator of the first compiler.
  • 5.
    © 2015 Starsoft.All Rights Reserved. 2002 – ISO COBOL-2002 (OOC) 1959 – Short Range Committee - COBOL-60 1968 – American National Standards Institute – ANSI COBOL-68 1974 – ANSI COBOL-74 1985 – ANSI COBOL-85 1997 – ISO (Committee Draft) Draft – Object Oriented Cobol Grace Hopper pioneered the implementation of standards for computer systems
  • 6.
    © 2015 Starsoft.All Rights Reserved. From the ISO 2002 Cobol standard
  • 7.
    © 2015 Starsoft.All Rights Reserved. a compute a = b + c b c Cobol program - A simple program Entry point Variables Procedure Program One program entry point One common memory
  • 8.
    © 2015 Starsoft.All Rights Reserved. Cobol program – Multi-procedural One program entry point One common memory for all procedures a compute a = b + c b c d compute d = e + f e f Entry point 1 Procedure 1 Procedure n Entry point n Variables pnVariables p1 Program
  • 9.
    © 2015 Starsoft.All Rights Reserved. a compute a = b + c b c d compute d = e + f e f The analogy in Object Oriented Cobol Entry point 1 Procedure 1 Procedure n Each procedure has its own entry point Each procedure has its own memory Each procedure is invoked individually Entry point n Variables pnVariables p1 Program
  • 10.
    © 2015 Starsoft.All Rights Reserved. Variables p1 a compute a = b + c b c d compute d = e + f e f The OO-Cobol Class Entry point 1 Method 1 Method n Entry point n Variables pn In Object Oriented Cobol, as in Java – o a procedure is called “method” o methods are defined in a “Class” Class
  • 11.
    © 2015 Starsoft.All Rights Reserved. OO-Cobol – Class Write the Cobol source that defines the Class a compute a = b + c b c Method Method Variables Class
  • 12.
    © 2015 Starsoft.All Rights Reserved. OO-Cobol – Program invokes Class Write the Cobol source of the Program that will use the Class a compute a = b + c b c Method Method Variables Class invoke method… Program Declare a reference to the Class in the program The program can then invoke methods of the Class
  • 13.
    © 2015 Starsoft.All Rights Reserved. For example a compute a = b + c b c Method “COMPUTE_SALARY” Method Variables NAME ID DAILY_SALARY Class “Employee” invoke method COMPUTE_SALARY Program EMP_CALC OO-Cobol – Program invokes Class
  • 14.
    © 2015 Starsoft.All Rights Reserved. Class Definition Class Variables OO-Cobol – Defining a Class
  • 15.
    © 2015 Starsoft.All Rights Reserved. Method – “new” OO-Cobol – Class Methods Just like a cookie cutter is used to create cookies, the Class serves as a template for creating a live instance of itself – an object. The “new” method creates the object that will be used by the program.
  • 16.
    © 2015 Starsoft.All Rights Reserved. Method – “new” OO-Cobol – Class Methods The “new” method giving us access to an object is similar to turning the ignition key in a car – once we do so, we can use the functions that the car has to offer: driving, braking, honking and so on.
  • 17.
    © 2015 Starsoft.All Rights Reserved. Method - Compute Method – Set OO-Cobol – Examples of other Class Methods
  • 18.
    © 2015 Starsoft.All Rights Reserved. Declaring the Class in the invoking program is analogous to declaring a file in the INPUT-OUTPUT section OO-Cobol – Referencing the Class
  • 19.
    © 2015 Starsoft.All Rights Reserved. Defining the object to be used in the invoking program is analogous to defining the file record in the FILE section OO-Cobol – Defining the object
  • 20.
    © 2015 Starsoft.All Rights Reserved. OO-Cobol – Example of invoking the “new” method
  • 21.
    © 2015 Starsoft.All Rights Reserved. OO-Cobol – Example of invoking the “GET_NAME” method
  • 22.
    © 2015 Starsoft.All Rights Reserved. OO-Cobol – Objects Like putting a “new” coin in a slot machine “returns” a new ball to play with each time, the program can work with a number of objects at the same time.
  • 23.
    © 2015 Starsoft.All Rights Reserved. OO-Cobol – OO implementation Encapsulation Restricting access to an Object’s components For example – Using method variables instead of global WORKING-STORAGE Creating a sub-type of a Class while reusing its code and memory definition Example – Defining a Class for computing salaries for Employees and Managers Polymorphism Inheritance Invoking the same method name in different objects, different parameters Example – “CALCULATE_SALARY” for both Manager and Employee
  • 24.
    © 2015 Starsoft.All Rights Reserved. Class Definition - Inherits Class Variables OO-Cobol - Inheritance
  • 25.
    © 2015 Starsoft.All Rights Reserved. Method – “new” OO-Cobol - Inheritance
  • 26.
    © 2015 Starsoft.All Rights Reserved. Method Override – COMPUTE_SALARY OO-Cobol - Inheritance
  • 27.
    © 2015 Starsoft.All Rights Reserved. OO-Cobol – Java integration Using Java Class String in an OO-Cobol program
  • 28.
    © 2015 Starsoft.All Rights Reserved. OO-Cobol – Java integration Using JSON object
  • 29.
    © 2015 Starsoft.All Rights Reserved. OO-Cobol – Java integration Send/Receive JSON data via Ajax with AngularJS client Use hashmaps to store data Define and use Java arrays (OCCURS DYNAMIC) Define and use Java variable types such as String (PIC X ANY LENGTH) Run as servlet under webserver using HTTP session Monitor performance using standard Java performance tools These are just a few of the possibilities that open up for you when you by using Object Oriented Cobol – getting the best of both worlds
  • 30.
    © 2015 Starsoft.All Rights Reserved. Thank you. And one final word about Grace Hopper…
  • 31.
    © 2015 Starsoft.All Rights Reserved. While she was working on a Mark II Computer at Harvard University in 1947, her associates discovered a moth stuck in a relay and thereby impeding operation, whereupon she remarked that they were "debugging" the system. The remains of the moth can be found in the group's log book at the Smithsonian Institution's National Museum of American History in Washington, D.C.