A Closer Look at Objects

This chapter covers the mechanics of using objects in more detail. First, a quick refresher.

A Rexx object consists of:

Sending a message to an object causes it to perform a related action. The method with the matching name performs the action. The message is the interface to the object, and with information hiding, only methods that belong to an object can access its variables.

Objects are grouped hierarchically into classes. The class at the top of the hierarchy is the Object class. Everything below it in the hierarchy belongs to the Object class and is therefore an object. As a result, all classes are objects.

In a class hierarchy, classes, superclasses, and subclasses are relative to one another. Unless designated otherwise, any class directly above a class in the hierarchy is a superclass, and any class below is a subclass.

From a class you can create instances of the class. Instances are merely similar objects that fit the template of the class; they are "of" the class, but are not classes themselves.

Both the classes and their instances contain variables and methods. The methods a class provides for use by its instances are called instance methods. The instance methods define which messages an object can respond to.

The methods available to the class itself are called class methods. Many of the methods are actually the instance methods of the Class class, but a class many have its own unique class methods. They define messages that only the class-and not its instances-can respond to.


Instance Methods and Class Methods