>I have read in several messages, including some in reponse to my own inquiries, that use of public variables is not good practice. If so, what are the primary reasons?
Public variables can be changed by any called subroutine. This is not an OOP issue because the the ramifications of this affect procedural code as well as objects. If you use a public variable and you call a subroutine that uses and automatically scoped variable (not declared local, local, private, or public), any values the subroutine assigns to "its" variable will change the value of the global (public) variable. This can cause all sort of unexpected and hard to find side effects.
Précédent
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement