General comparison with procedure-based programming
- Last Updated: May 29, 2019
- 2 minute read
- OpenEdge
- Version 13.0
- Documentation
There is no expectation that you will convert existing procedural ABL applications to use classes unless you have a reason to do so. The language statements supporting classes provide options for object-oriented programming, and you can choose to take advantage of these options when they are beneficial to you. This section summarizes and compares a few key differences between using procedures and using classes in your development.
When multiple procedures need to access the data in a temp-table or a ProDataSet, the temp-table or the ProDataSet and its temp-tables are routinely defined in an include file and included in all procedures that need access to the temp-table or ProDataSet. In this way the definitions only need to be written once and you have assurance that the definitions are consistent between all the procedures that use them, and that a change to the definitions is propagated to all procedures that use them simply by recompiling them. The temp-table or ProDataSet can then be passed between the procedures as a parameter. Other documentation describes how to pass both ProDataSets and temp-tables by reference, so that they are not copied from one procedure to another (see Develop ABL Applications and Use ProDataSets).
Within a class hierarchy a super class can define a PROTECTED temp-table
or ProDataSet whose definition is implicitly shared among all the
subclasses of that super class. There is no need to repeat the definition
in each subclass. (Indeed, it would be a compiler error to repeat
the definition). If the methods that access the common data held
in a temp-table or ProDataSet are all in the same class hierarchy,
then they can all access the data through its one PROTECTED definition,
without the need to pass the temp-table or ProDataSet as a parameter.
Similarly, variables and other data definitions that might be
defined as SHARED in procedure-based ABL applications
can be defined as PROTECTED within a class hierarchy.
However, note that classes cannot define or access the SHARED variables
used by procedures.
Also, you cannot specify a class file (either source code or r-code) as a
startup routine using the Startup Procedure (-p) startup
parameter. You can only start up an application (whether procedure-base or class-based) using
a procedure file.