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

I have a public variable that is called MakingEXE.

Before I compile, I set it to .T.. Otherwise, it is set it to .F..

When I re-write a chunk of code, I will do this:

if MakingEXE
do old code here
else
do this new, untested code
endif

With this technique, I can re-write sections of code and if I need to make a quick change to another section, I can do that without worrying about sending untested code out to the users.

I did this a long time ago and I haven't changed it because I think it works well.

I also have other sections of code that have tightly coupled routines. But they are routines that will never be used elsewhere. Sometimes it is just to get a chunk of code out of the way. Like, these 50 lines basically do one thing, so make them a procedure called OneThing and when reading the code (in the calling routine), it looks cleaner (ie. do OneThing as opposed to 50 lines of code with a comment saying * This section does one thing). Will the called procedure ever be used elsewhere? No. Is it too tightly coupled to be used elsewhere without great difficulty? Yes. Do I lose sleep over it? No.

I think there are always exceptions to the rules. Of course, generally, I agree with the rules.

Take care,
Joe
Joseph C. Kempel
Systems Analyst/Programmer
JNC
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform