publicvar

replace public variable &1 by property

Rule "publicvar" gives this warning when it finds a DEFINE PUBLIC VARIABLE statement in a class. The statement should be replaced by a (public) PROPERTY.

Motivation

Encapsulation: a class is responsible for its own state. A public variable allows other objects and procedures outside the class to manipulate the state of the class, so that can't be right.
Replacing the variable with a PROPERTY with a SET accessor gives control back to the class: the accessor is triggered each time the property value changes. Wether or not the SET accessor is empty is beyond the scope of this rule.

Known issue

Prolint assumes that "CLASS" is the very first statement in a class file, and the implementation of this rule is based on that assumption. However in OpenEdge 10.1B the new statement "USING" can be placed before "CLASS". We will have to fix that in Prolint later.