Guideline 3: Make super procedure code shareable
- Last Updated: October 15, 2024
- 2 minute read
- OpenEdge
- Version 12.8
- Documentation
If you write a super procedure as a library of general-purpose code, it makes sense that in
most cases it should be shareable. The use of TARGET-PROCEDURE
facilitates this. If the routines in a super procedure always refer back to the
TARGET-PROCEDURE, then they always get data values from the
procedure they currently support, that is, the procedure they were invoked from. To make
sure that stale data is not left over from call to call, the general rule is to have no
variables or any other definitions scoped to the super procedure main block. You should
place all definitions within each individual internal procedure or function, so that
they safely go out of scope when the routine exits.
This also means that you should structure your application so that only one instance of each super procedure starts for a session. The following example uses the simple mechanism of checking existing procedure handles and their filenames to see if the super procedure is already running, as shown in this procedure:
|