top of page
Writer's pictureDonald Wickham

Introduction to Object Oriented Programming (OOP)

Updated: Dec 29, 2022

OOP or Object Oriented Programming has been around for years.  But many of us who have been using COBOL, TAL or C, have nothing to help us relate to this “new” approach to application development.  Most of us have experience with “called modules”, libraries and functions, but not “objects” nor in how to benefit from using them. Programming languages such as Java and C++ are built on OOP concepts. If you are interested in learning those languages or using them on NonStop, you should start with the basics I have outlined here.

In this article we will take a very high level look at objects and some of their benefits.

  • What is OOP? Object Oriented Programming Combining code and data into “objects” that can be reused and whose internal structure is transparent to the object’s consumer.

  • Why use OOP?

    • Emphasis on data rather than procedure

    • Programs are divided into Objects

    • Data is protected and cannot normally be accessed by external functions

    • Objects can communicate with each other through functions

    • New data and functions can be easily added whenever necessary

    • Follows bottom-up approach

  • What is an object? An object can be considered a “thing” that can perform a set of related activities and has defined attributes or properties. The set of activities that the object performs and its attributes define the object’s behavior.  In some ways a Cobol “called program” has some characteristics of an object.  A serverclass program could be considered like an object.

  • What is a class? A class is simply the representation of a type of object. It is the blueprint/ plan/ template that describe the details of an object. A class is the blueprint from which the individual objects are created. Classes are composed of three things: a name, attributes or properties, and operations or methods.  In some ways, the DDL definition of a request and reply is similar to some aspects of a class.

  • What is an object instance? An object or class instance is created when that class is used.  As an example, let’s say there is a Hand object.  A human has two instances of Hand, right and left.  And each person has their own, unique, instances of Hand.  The attributes of a specific Hand instance will vary: size, color, amount of hair, whether it is a right or left hand etc.

An individual process of a serverclass would be an example of an instance.

  • What is inheritance? When a class is defined, it can inherit from one or more other classes.  Attributes and methods of the parent classes are inherited, much like a child inherits features from their parents.  As an example, let’s start with a telephone class.

  • A base object – Telephone

    • Attributes

      • Phone number

      • Dial type

      • Service Provider

    • Operation

      • Make Call

      • Answer Call

We will create some derived classes from Telephone.  They will all inherit the base class’s attributes and operation.  But they can add attributes and/or operations as needed.

  • Cell Phone derived from Telephone

    • Attributes (in addition to Telephone’s)

      • Text messages

      • Pictures

  • Operations (in addition to Telephone’s)

    • Messaging

    • Camera


  • Smart Phone derived from Cell Phone

    • Attributes (in addition to Cell Phone’s)

      • Applications

    • Operations (in addition to Cell Phone’s)

      • Email

      • Web Browsing

What is encapsulation? Wrapping a set of operations and data to simplify, protect and standardize.  As an example, look at NonStop Enscribe files.  There are 4 basic types, EDIT, key-sequenced, relative and unstructured.  Creating, reading, writing and updating have unique requirements based on the underlying file’s type.  It is possible (and recommended) that classes can be created to “wrap” or “encapsulate” what needs to be done for the each file type.

  • NonStop File

    • Attributes

      • File name

      • File Type

      • Operations

        • Create

        • Open

        • Read

  • EDIT File derived from NonStop File

    • Attributes (same as NonStop File)

    • Operations

      • Create (overrides base class for unique handling)

      • Open (overrides base class for unique handling)

      • Read (overrides base class for unique handling)

As you can see, there are new terms and concepts to grasp for OOP.  In future articles we will explore how these can be used.

 

Feedback please

Do you find this tutorial blog helpful? Let us know what you think, and how we can make it even better. Don’t forget, you can subscribe to our blogs to get automatic email notification when a new blog is available.

 

Donald Wickham has 31 years experience with Nonstop including 20 years for Tandem, Compaq and HP. He has been with TIC Software for 11 years in the role of Chief Architect.

 

TIC Software, a New York-based company specializing in software and services that integrate NonStop with the latest technologies, including Web Services, .NET and Java. Prior to founding TIC in 1983, Phil worked for Tandem Computer in technical support and software development.

Comments


Categories

Archive

bottom of page