Define classes
- Last Updated: May 29, 2019
- 3 minute read
- OpenEdge
- Version 13.0
- Documentation
ABL allows you to define a class as a named block that
always begins with the CLASS statement and always
ends with the END CLASS statement. The source code
for a CLASS statement can appear only in a class
definition file (.cls file type), and a class
definition file can contain only one such CLASS statement. This
statement defines the class type name that any other class or procedure
can use to reference the defined class and that any subclass can
use to inherit from this class. (For more information on class definition
files, see Class definition files and object type names.)
This statement can also optionally identify the type name of a super
class that the defined class inherits from, as well as one or more
interfaces specifying member prototypes (properties, methods, or events)
that the class must implement (see the ). The class can define itself
as FINAL, which prevents it from being inherited
by a subclass. The class can alternatively define itself as ABSTRACT,
which requires that it be inherited by a subclass. Classes are always
public, which means they are always accessible to other classes
and procedures.
A class can contain similar kinds of definitions for data elements and executable code as in procedures. However, the data elements and executable code of a class is organized into strongly-typed class members, including data members, properties, methods, and events, that can be inherited from one class by another. If the class is abstract, it can also define any properties, methods, and events as abstract. Abstract class members must be implemented by a subclass that inherits them, similar to the members of an interface that a class implements.
The main block of a class can contain non-executable statements that define:
- Any number of data members, including ProDataSets, data-sources, temp-tables, buffers, queries, and simple variables. (See Define data members.)
- Any number of properties, which are class members similar to simple variables, but with associated behavior. (See Define properties.)
- Any number of named methods, which are members that define class behavior. (See Define methods.)
- Any number of class events, which are members that support behavior based on named methods or internal procedures that can be dynamically configured to execute in response to run-time conditions. (See Define class events.)
- Any number of optional constructors, which are special methods that define initial behavior for a class. (See Define constructors.)
- An optional destructor, a special method that defines final behavior for a class. (See Define the destructor.)
- Any number of static definitions for class-scoped handle-based objects, including widgets, streams, and work-tables that provide associated ABL resources to the class, but are not themselves class members. (See Define class-scoped handle-based objects.)
- Any number of
ONstatements, which specify ABL triggers for widget and other low-level handle-based object events managed as part of class behavior. (See theONstatement reference entry in ABL Reference.) - Any number of user-defined function prototypes (not the function
definitions themselves) for user-defined functions called in the class. (See
the
FUNCTIONstatement reference entry in ABL Reference.)
The main block of a class cannot contain any executable statements that are outside of a method, constructor, destructor, or ABL trigger definition.
For information on the ABL to use a class type, see Use object types. For more information on defining classes, see Define classes.