You are on page 1of 19

Presented by:

Tim O’Brien
Senior Systems Engineer
Fujitsu Software Corporation

OO Programming

Fujitsu Software Corporation

Customer Training Series

Fujitsu Computer Systems


Intro to Object Oriented COBOL

■ Discussion of OO Concepts
 Objects
 Methods
 Encapsulation
 Inheritance
 Polymorphism
 Properties
 Attributes Classes

PAGE 2 Fujitsu Computer Systems


Intro to Object Oriented COBOL (Cont…)

■ Create a simple Hello World COBOL Class

■ Discussion of OO COBOL Syntax

■ Create a multi-class OO COBOL Application

PAGE 3 Fujitsu Computer Systems


OO Concepts – Classes
■ Classes are collections of Objects that have common
attributes and behaviors

■ Abstract Classes are Classes that do not necessarily


correspond to specific real world objects. They are more
like templates

■ Objects are instantiated from Classes

■ A Class can typically be thought of as a factory that


produces Objects at Runtime

PAGE 4 Fujitsu Computer Systems


OO Concepts - Objects
■ An object is a software component – an instance
of a program

■ An object typically has data and methods

■ An object may have properties and/or attributes

PAGE 5 Fujitsu Computer Systems


OO Concepts – Objects (Cont…)

■ An object typically encapsulates its data by


forcing external programs (other objects) to go
through one or more of its methods to access its
data

■ Objects are instantiated

PAGE 6 Fujitsu Computer Systems


OO Concepts – Methods
■ Methods are like functions or subroutines – like
mini programs within a program

■ Methods may accept and/or return parameters


(data)

■ Methods are Invoked (called) using messages

PAGE 7 Fujitsu Computer Systems


OO Concepts – Methods (Cont…)

■ Method Prototypes are used to define interfaces


into other Objects and/or to aid the compiler and
runtime system to perform conformance
checking

PAGE 8 Fujitsu Computer Systems


OO Concepts – Properties
■ A Property is a fixed data item with a well
defined format which can only be retrieved
and/or set

■ In OO COBOL, Properties are both internally


and externally available (Public) by default

PAGE 9 Fujitsu Computer Systems


OO Concepts – Attributes
■ An Attribute is a declarative that may be
specified or queried at runtime

PAGE 10 Fujitsu Computer Systems


OO Concepts – An Object and
Encapsulation Diagram

Method A

DATA

M et h
C od

od B
M e th

PAGE 11 Fujitsu Computer Systems


OO Concepts – Inheritance
■ Inheritance allows programmers to reuse code
and may dramatically decrease the time required
to create new applications

■ Inheritance is supported in Object COBOL. This


means a child class may inherit from a parent
class, thus combining functionality

PAGE 12 Fujitsu Computer Systems


Discussion of OO Concepts –
Inheritance Diagram

Method A
Method A

M ethod B
C
DATA DATA

od
M eth
od C

M e th
od B
M e th

Method D

PAGE 13 Fujitsu Computer Systems


OO Concepts – Polymorphism

■ Polymorphism allows programmers to inherit


from classes, but to alter (customize) inherited
classes for specific usage needs

■ Using Polymorphism, the same method name


may perform slightly different operations on
different objects in different circumstances

PAGE 14 Fujitsu Computer Systems


OO Concepts – Polymorphism Diagram

Method A
Method A

M ethod
DATA DATA

od
M eth

B+
od C

M e th
od B
M e th

Method D

PAGE 15 Fujitsu Computer Systems


“Hello World” COBOL Class
■ Create a new COBOL Project in Visual
Studio .NET
■ Add a new class
■ Code the class to display “Hello World”
■ Build and debug the application

PAGE 16 Fujitsu Computer Systems


OO COBOL Syntax
■ Creating COBOL Classes
■ Creating Properties
■ Creating Methods
■ Using existing COBOL syntax
■ Invoking COBOL Classes

PAGE 17 Fujitsu Computer Systems


A Multi-class OO COBOL Application

■ Add class modules to a COBOL project


■ Code the modules
■ Create an application that illustrates
encapsulation, inheritance, use of
properties and methods, and
polymorphism
■ Build and Debug the application

PAGE 18 Fujitsu Computer Systems


Questions

PAGE 19 Fujitsu Computer Systems

You might also like