Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Best approach about #DEFINE constants
Message
From
15/05/2008 20:28:24
Mike Yearwood
Toronto, Ontario, Canada
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
01316940
Message ID:
01317514
Views:
10
>>>You may have one public global object (or _screen) and have these constants to be its properties.
>>>
>>>Or you would have to include this include file in every form / program where you want to use them.
>>>
>>>I see no other better way in VFP.
>>
>>Actually, no. You would learn more by accepting that public variables are not recommended and trying to get away from them completely. Properties on the public object that are also public are no better than public variables.
>
>Ok, what you're suggesting to use for GLOBAL constants in VFP?

Well, you've gotten several replies. You've already learned that privates at the top level are almost identical to public. However, the danger with public and even with pseudo public private variables is the ability for any running code to overwrite the content of the variables, with possibly drastic impact throughout the system.

I saw such a thing once. It was a fatal flaw - literally. The system would have resulted in a patient deaths all because of changing one public variable.

I think an application object which reads a table or ini file to get the initial values and makes the values read-only is safest. Such an object could be declared at the start of the app with private or public or bound to _screen. It could instantiate a parameter object used to hold the "public" variables. All values would be protected and accessible via get/set methods.

If some code removes the application object, an error handler could shut the app down or reinstantiate the application object and the "public" variables.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform