Try OpenEdge Now
skip to main content
GUI for .NET Primer
Object-oriented Programming in ABL : Classes : Inheritance
 

Inheritance

Inheritance of common data and behavior is at the core of object-oriented programming. A class inherits the non-private data members, properties, methods, and events of its super class (also referred to as the base or parent class). The inheriting class can also extend the interface of its super class by defining its own members, making all of its inherited and defined non-private members available for inheritance by another class (a subclass). In this way, each class in a class hierarchy derives its interface based on the super classes above it.
One of the key benefits of inheritance is code reuse, coupled with defined relationships between classes. The compiler cross-checks the contents of super classes and subclasses in a class hierarchy at compile time, which is not done for procedures. In an inheritance hierarchy of ABL classes, a method in a subclass can also override and redefine a method of the same name and signature in a super class. In this case the most-derived (inherited) version of the overridden method is invoked at run time.
Compared to internal procedures and user-defined functions which have no inherent relationships among them, object-oriented inheritance provides for organizing classes and factoring out common elements of related classes. You can also define a form of inheritance with procedure objects using super procedures. A set of related super procedures can act in much the same way as a class hierarchy, but their relationships are validated at run time.
These are some notable ABL elements for working with inherited classes:
*INHERITS option, CLASS statement — The INHERITS option specifies the super class from which your derived class inherits. If you do not specify a super class, all ABL user-defined classes derive from the top-level super class (root class), Progress.Lang.Object, by default. Thus, the interface defined by every ABL class includes members inherited from this ABL root class.
*METHOD, DEFINE PROPERTY, DEFINE EVENT, DEFINE VARIABLE, and various other DEFINE statements — These statements allow you to extend the inherited interface with additional methods, properties, events, and data members of various types.
*OVERRIDE option, METHOD statement — When an ABL class inherits a class, it can modify behavior of the base or parent class by overriding public and protected instance methods in the inherited class hierarchy with its own ABL OVERRIDE methods.
*SUPER statement — The SUPER statement invokes a constructor for the immediate super class as the first statement in a constructor of the defining class.
*THIS-OBJECT statement — The THIS-OBJECT statement invokes a constructor defined in the current class definition.
*SUPER system reference — Using the SUPER system reference, a subclass can call the PUBLIC and PROTECTED instance methods of its super class in the inherited class hierarchy. If the specified method definition is not found in the subclass's immediate super class, the ABL compiler repeatedly looks to the next super class in the inherited class hierarchy until it finds the definition.