Quizzes & Puzzles26 mins ago
Best way to access instance variables??
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?
Answers
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...
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...
10: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.
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.
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.