Class hierarchies and procedure hierarchies
- Last Updated: June 13, 2014
- 2 minute read
- OpenEdge
- Version 13.0
- Documentation
A class can inherit from (extend) only one other class.
However, a class can be extended by any number of other classes
(see ). A class hierarchy represents all the classes that a class
inherits either directly or indirectly through multiple levels of
inheritance. The root of a class hierarchy is a class that does
not extend any other class. The entire class hierarchy is treated
as a single object type. You can logically think of a class as the
merging of its own members with all of the non-private members of
all the classes above it in the hierarchy, including the members
of the built-in root class, Progress.Lang.Object.
To illustrate this, consider the hierarchy for the sample user-defined
classes (see Sample classes), where acme.myObjs.Common.CommonObj is
the top user-defined super class (base class), acme.myObjs.CustObj inherits
from acme.myObjs.Common.CommonObj, and acme.myObjs.NECustObj inherits
from acme.myObjs.CustObj, represented as follows:
|
A class definition can override a non-private method in its class hierarchy by providing a
method definition with the same name, return type, number of parameters, and corresponding
parameter types as the method in its class hierarchy. For example the sample
acme.myObjs.CustObj class has a method GetCustomerName( )
that returns the name of a customer, and the acme.myObjs.NECustObj class
overrides the GetCustomerName( ) method to provide both the name and E-mail
address of the customer. In addition, any non-private data is available to all subclasses of
the super class that defines it.
Also, the acme.myObjs.Common.CommonObj class is abstract and
all of its abstract members (which can include properties, methods,
or class events) must be overridden and implemented by the first
derived non-abstract class, in this case acme.myObjs.CustObj.
For example, acme.myObjs.CustObj overrides and
implements three abstract members, including the OutputGenerated event
and the two methods, PublishOutputGenerated( ) and MessageHandler( ).
Finally, the data type of an object can be referenced as any
class or interface type that is part of its class hierarchy. For
example, an object instantiated as the acme.myObjs.NECustObj class
can be referenced as the acme.myObjs.Common.CommonObj class. However,
if it is so referenced, only the accessible class members defined
within CommonObj or its inherited class hierarchy
can be referenced using the object. Note that if CommonObj is
an abstract class (as in the sample classes), you can also reference
any of its accessible abstract members, because they are guaranteed
to be implemented in some derived class.