Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Public variables
Message
From
12/12/1998 12:53:02
 
 
To
12/12/1998 09:57:48
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00166872
Message ID:
00166894
Views:
18
>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?

There are several reasons. From the practical side, PUBLIC variables are subject to accidental changes in value as a result of accidental side effects; a PUBLIC variable is visible in any procedure or method, and with the habit of many VFP programmers to do an assignment to a variable on the fly (if it doesn't exist, VFP creates it with a scoping of PRIVATE), the value can be changed unexpectedly. You can control the scoping and visibility of things much better with LOCAL/PRIVATE variables and member properties of objects.

It's tough to track down side effects that alter PUBLICs.

From an OOP theory standpoint, PUBLIC variables are not desirable because of scoping and encapsulation issues.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Reply
Map
View

Click here to load this message in the networking platform