Getter and setter policy

From CSSEMediaWiki
Revision as of 06:24, 27 July 2009 by AlexGee (Talk | contribs)
Jump to: navigation, search

Objects should store all their data in private variables. Getter and setter methods should be produced for any variable you might have been tempted to declare public. Classes should ideally call their own getter and setters when accessing their internal data. This prevents the object getting into a invalid state.

Some complications may be encountered when classes contain collections that require non-transactional access.

Personal tools