Mapping Abstraction and Separation to Software



Learning how to use existing classes to create and manipulate objects is the first step in learning about object-oriented programming. As a user, you are able to benefit from the hard work already done by the designer and implementor of existing classes. This ability to reuse existing classes is one of the major benefits of software reuse, in general, and object-oriented programming in particular.

From an object-oriented point of view, software development centers on forming abstractions of entities and rendering thse abstractions in a form that allows them to be manipulated within the software system. Object-oriented programming differs from other forms of programming in how the abstraction is rendered, or captured, in a software form. As shown in the figure below, the attributes of an abstraction are mapped to a set of data (variables, array, lists, complex data structures, etc.) and the behavior of an abstraction are mapped to a set of methods (also known as operations, member functions, actions). A method is represented by its signature, a name and a list of argument types.

Mapping Abstractions to Software

An object provides a structure using which the data and methods can be organized. The key aspects of the object structure, as shown below, are:

This separation of encapsulated data and visible method signature is motivated by long years of software engineering experience showing that it is important to protect the data against unexpected, unwanted and erroneous access from other parts of the software that is manipulating the object. It is also useful to hide the algorithm that a method uses to perform a method.

The General Structure of an Object

The specific structure of a given object (what data it has, what methods it has, how its methods are implemented) are defined in a class. The structure is not defined for each object, as there are usually many objects that have the same structure. A program might have many objects that are Windows or many objects each of which is a SalesPerson. The class definition allows the common structure to be defined once and reused when creating new objects that need the structure defined by the class. It is interesting to note that there are object-oriented languages that do not have classes but use other techniques to achieve a similar effect.

The class has a name and is divided into two parts, commonly named the private part and the public part. The data and methods are mapped to these two parts of the class as shown below.

The General Structure of a Class

A class is a uniquely named description that can be used to create objects. An object's properties are exactly those described in the class from which it was created. Each class has a unique name. The relationship between a class and the objects that can be created using the class is often likened to that of a factory and the things produced by that factory. An automobile factory produces automobiles in the same way that an Automobile class can be used to create Automobile objects. Also, an Automobile class can produce only Automobile objects just as an automobile factory can produce only automobiles, not vacuum cleaners or rocket ships.

Last Updated: May 21, 1996 / kafura@cs.vt.edu