Donate SIGN UP

Best way to access instance variables??

Avatar Image
george173 | 19:33 Tue 15th May 2012 | Technology
1 Answers
I was wondering what the best (most effective way) of accessing instance variables in a class is?? Would the best way be though methods (such as a return method) or directly manipulating the variable?
Gravatar

Answers

Only 1 answerrss feed

Avatar Image
The variables should be Private and encapsulated as properties of the object with Property Get and Let functions to save and retreive them. This allows for validation when they are stored and a default to be included.

Where the variable is dependent on other Methods it should be read only (no Let function) so that they cannot be written to other than via...
11:25 Wed 16th May 2012
The variables should be Private and encapsulated as properties of the object with Property Get and Let functions to save and retreive them. This allows for validation when they are stored and a default to be included.

Where the variable is dependent on other Methods it should be read only (no Let function) so that they cannot be written to other than via the outcomes of the method.

None of this is possible with direct access to a Public variable.

Only 1 answerrss feed

Do you know the answer?

Best way to access instance variables??

Answer Question >>

Related Questions

Sorry, we can't find any related questions. Try using the search bar at the top of the page to search for some keywords, or choose a topic and submit your own question.