Mon 2 Jul 2007
Access to Instance Variables within the same Class
Posted by ChiliJoe under PeopleSoft • PeopleCode • Experiments[2] Comments
In PeopleSoft application classes, instance variables are analogous to private variables in most object-oriented languages. This means that instance variables are inaccessible from PeopleCode outside the class where it is declared. I used to assume that a specific object (instance of a class) would only have access to its own instance variables. This appears not to be the case, as the following paragraphs in PeopleBooks (PeopleCode API Reference > Application Class > Self-Reference) states:
If you declare an instance variable as private you can still access it as a private property in another instance of the same class. For example, given the following declaration:
class Example private instance number &Num; end-class;A method of Example could reference another Example instance’s &Num instance variable as follows:
&X = &SomeOtherExample.Num;