Try OpenEdge Now
skip to main content
Object-oriented Programming
Designing Objects: Inheritance, Polymorphism, and Delegation : Class hierarchies and inheritance : Data member and property scoping within a class hierarchy : Comparison with procedure-based programming
 
Comparison with procedure-based programming
Variables and other types of data definitions are also implicitly PRIVATE when used in procedures. You can achieve something like the PROTECTED capability using procedures by defining variables and other types of data as NEW SHARED in a parent procedure and as SHARED in a subprocedure. Shared data elements require that the definitions be repeated as SHARED in each subprocedure that shares them, which is typically done using an include file containing all of the definitions, so that they are guaranteed to match in all procedures that use them. The match between the NEW SHARED and corresponding SHARED definitions is verified at run time. However, the PROTECTED access mode also allows you to access data members and properties defined throughout the hierarchy without having to repeat the definitions in each class that uses them, and access to these PROTECTED class members is verified at compile time.
PUBLIC data members and properties really have no correspondence in procedure-based data, except for PUBLIC data members and properties that are also static. PUBLIC static class data elements are similar to GLOBAL SHARED data elements in procedures, because both are scoped to the session and cannot be deleted. For more information on static data members and properties, see Usingstatic members of a class.