Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Table from Array
Message
From
07/03/2005 08:53:40
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
07/03/2005 08:43:09
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
00993044
Message ID:
00993255
Views:
18
>I have two questions:
>
>1) Why are public variable such a horrible thing?

A public variable is a shared space, accesible from all programs. This makes it hard to control your program. Some procedure might unexpectedly do a change, and you will have a hard time finding out which one it was.

>2) If they are as bad as so many developers claim, why are they part of VFP?

In some cases, they are unavoidable. For example, you do need some public variables, to store information about your application in general, accesible from different procedures, forms, etc.

However, since an object can contain many different variables (properties) a single "application object" might be sufficient to store all your global data.

Also, in some cases it is tricky to exchange data between forms; a global variable can be an easy solution. But it is preferable to search for alternative methods.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform