Class hierarchies and inheritance
- Last Updated: October 30, 2020
- 3 minute read
- OpenEdge
- Version 12.2
- Documentation
Class hierarchies and inheritance
One of the great powers of object-oriented programming
is inheritance, which facilitates code reuse and polymorphism (see Polymorphism). The CLASS construct
supports single inheritance of classes. This inheritance allows
a class (as a derived class or subclass) to extend another class
(its super class). The subclass inherits all the non-private data
members, properties, methods, and events of the super class so they
appear as if they are part of the subclass. The super class itself
might be a derived class that extends its own super class, forming
a class hierarchy from the resulting series of super class and subclass relationships.
Thus, through this chain of inheritance, a derived class inherits data
and behavior from all the super classes in its class hierarchy,
including the root class, the super class at the top of the hierarchy.
The root class of a hierarchy is the class that does not inherit
from any other class. In ABL, the root class of all classes is the
built-in, non-abstract class, Progress.Lang.Object.
The following figure shows the sequence of class construction and inheritance during instantiation of a class hierarchy.

The numbered arrows show the order in which execution occurs during construction of the class hierarchy.
So, an instantiated class (an object) actually represents a hierarchy
of classes, with the root class (Progress.Lang.Object) at
the top and the instantiated class as the most derived class at
the bottom (ClassC). When a class is instantiated, the specified
constructor for each class in its class hierarchy is executed as
part of the instantiation process. The AVM first invokes the constructor
in the instantiated class (ClassC) of the object. The first action
of the instantiated class’s constructor must be to invoke a constructor
in its immediate super class (ClassB), whether implicitly (for the
default constructor) or explicitly (especially if parameters must
be passed).
This super class constructor, in turn, invokes a constructor
in its own immediate super class (ClassA). This chain of super class
constructor invocation continues to the root class (Progress.Lang.Object).
When the root class's constructor is invoked, it executes to completion.
Execution then returns to its caller, its immediate subclass (ClassA),
so that the subclass constructor can complete. This sequence continues
until the constructor in the most derived subclass (the originally
instantiated class, ClassC) completes. In this way, although instantiation
of a class always starts at the bottom of its class hierarchy, the
object representing this hierarchy is constructed starting from
the root class at the top.
Also, note that one or both of ClassA and ClassB can be either abstract or non-abstract classes. So, in an ABL class hierarchy, only the instantiated class (ClassC in the figure) must be fully implemented (non-abstract).