The CTDP Object Oriented Basics Guide Version 0.6.0, January 21, 2001

Object Oriented Basics

What is an Object?

If you are familiar with programming, you know that programming on a very basic level requires:

  • Code - The part of the program that allows functionality. Sets of instructions that tell the program how to operate or what to do.
  • Data - Where program and external information is stored. There are several data types such as integers, strings, float values and more. Data is called attributes in object oriented programming.

When writing code, the code is put into what is called procedures or functions. The classic difference between a procedure and a function is that a function returns a value when a procedure does not, however the terms function and procedure are sometimes used interchangeably.

In the real world, an object includes such things as:

  • Table
  • Chair
  • Car

You get the idea. In the computer world, objects are simulated using code and data. The data stores the current and permanent states of the object, and the code makes the object perform its functions (also known as behavior). For example in the case of a car permanent object data would include:

  • Make - The manufacturer of the car.
  • Model
  • Color
  • Engine horsepower
  • Transmission information
  • Passenger capacity

There are many more. The current object state describes characteristics of the object that would change with time such as:

  • Position or location
  • Speed
  • Fuel reserve
  • Mileage

To make an object perform functions the following types of functions may be required:

  • Start
  • Turn off
  • Accelerate
  • Decelerate
  • Turn number of degrees left
  • Turn Number of degrees right
  • Check fuel reserve
  • Fill fuel tank

As you can see an object requires the above items and more to make it what it is. Therefore objects in the programming world consist of:

Classes are used to implement objects. Classes are not objects themselves, but are used to create objects. An excellent comparison of classes and objects is to compare a class to a cookie cutter and the object is a cookie. Classes are templates for objects.

Object Oriented Basics Guide Contents Page