Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Where is the best place to declare public variables?
Message
From
24/08/2000 15:47:46
 
 
To
24/08/2000 15:12:09
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00408953
Message ID:
00408982
Views:
13
>Is it in a main.prg, or in the init event of a form, or at the beginning of a program?

If they're declared before they're needed, PRIVATE scoping works. There's a strong implication that something prevents declaration at the top of the app.

>Do I have to release all those variables after using them?

If you want them to go away, yes; otherwise, they stay in VFP closes.

>What happens if I don't?

They remain until you close VFP; side effects may present unexplained logic errors.

>I've seen some posts of people not wanting to use public variables. What's wrong with PV's?
>

They break encapsulation, so that the scope of influence of a routine that changes or examines a PUBLIC is not well-defined. In many cases, a PUBLIC really scopes to the life of an object rather than the whole app; you can use a member property instead of a PUBLIC to. Declaring them as PRIVATE at the proper level in the app forces you to examine the scope of things, resulting in a better understanding of the task at hand.
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