Skip to main content

Replacing A Session SuperProcedure With A Class In OOABL

Printer-friendly version

Progress Software has numerous references in documentation and whitepapers to the parallels between superprocedures and classes, including a fairly lengthy, if somewhat flawed example in the Getting Started: Object-Oriented Programming manual for 10.1A that shows two parallel examples, one worked using superprocedures and one worked using classes. However, what is not shown is an example in which a class replaces a superprocedure while retaining the original program structure as a set of procedures. For a local super-procedure, this substitution is simple because the class does not need to be accessible except from the procedure that instantiates it. For a session superprocedure, a different functionality is required because the internal procedures of the session superprocedure become a part of the name space of procedures that did not invoke the superprocedure.

In other object-oriented languages, one would immediately think that this requirement required a name service such as JNDI or the use of singletons. The use of a name service seems unattractive for something as “intimate” as a session superprocedure because the single-threaded nature of the Progress client seems to imply that the class would be running in a different session. However, OE10.1A does not include an implementation of singletons, so what does one do?

An example is provided in this document with accompanying sample code that illustrates a technique that addresses this problem by using the FIRST-OBJECT method of the session handle and the NEXT-SIBLING method on the object identified by the FIRST-OBJECT method to locate a previously instantiated instance of the object one desires to use in common. Before going into specifics, let us consider the example application that we desire to enhance.

Note that recent versions of Progress now have static methods which provide a better approach for the general "singleton" problem, but the technique shown here is still appropriate for earlier versions and is applicable to other classes of related problems which statics don't solve.

AttachmentSize
ReplaceAnSPWithAClass.pdf72.39 KB
ReplaceSPWithAClassCode.zip6.38 KB