Try OpenEdge Now
skip to main content
Object-oriented Programming
Programming with Class-based and Procedure Objects : Comparing constructs in classes and procedures
 

Comparing constructs in classes and procedures

The examples in the following sections compare the use of classes and inheritance with the use of procedures and super procedures. Almost the same application is implemented using a set of sample classes and procedures, which checks, adjusts, and reports on customer credit limits. A summary comparison between the class-based and procedure-based versions follows the listing of all the classes and procedures. The commented numbers in the code match code-numbered comments in the summary comparison.
Note that this is not a real-world application. It is designed solely to demonstrate object-oriented programming concepts, and it includes one possible implementation using procedure-based programming as a point of comparison with the class-based implementation. As a result, some constructs are artificially coded for point-by-point illustration and comparison. Little of this code is intended to demonstrate best practices for designing and implementing ABL applications. Indeed for brevity, some best practices might be intentionally avoided to illustrate a concept. For information on best practices, see the resources available on PSDN: http://communities.progress.com/pcom/community/psdn/openedge.
These sample classes and procedures are also available for compiling and running in your OpenEdge development environment.
Both versions of this sample application rely on the Customer table of the sports2000 database installed with OpenEdge. The samples are coded to filter out all but a few test records in the database. Before running these samples, you can also run the IncreaseBalance.p procedure that is duplicated for convenience in both the classes and procedures directories. This procedure updates some of the filtered test records to ensure that they have Balance fields with values greater than their corresponding CreditLimit fields. Also duplicated in these directories is a text file of sample E-mail addresses (email.txt) that is referenced by the samples. Be sure to move this file to the working directory that is appropriate for your environment.