Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP Monad Research
Message
From
19/01/2009 13:33:46
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
01375100
Message ID:
01375165
Views:
9
>* For da loop
>public lquit, ndotcolor, nstep
>lquit = .F.
>nstep = 0
>
>SetupScreen()
>
>* Setup Initial Conditions
>

public oAbsoluteMatter


>oAbsoluteMatter = createobject("collection")
>
>In your posted code there is no reason for the variables being declared to be PUBLIC. I don't know if this has anything to do with your question but it is an issue that is worth mentioning as the PUBLIC declaration only causes those variables to continue to exist beyond the end of the program. If you want your variables explicitly declared for clarity in your code then declare them as PRIVATE.
>
>PUBLIC is NOT synonymous with global. A private variable delcared as such in the highest level program of an application is "global" to that application. Declaring a variable PUBLIC does only one thing and that is to cause the variable to live longer than the program that declares it. A need for PUBLIC variables in an application should always cause one to review their application design as the need for a public variable indicates a really bad design problem related to a lack of encapsulation. To have a situation where a variable needs to be used by code that is not at or below the stack level of the variable's declaration is a serious problem waiting to cause trouble.
>
>Usually, as in the case of your example code, the public declaration is not necessary and is actually a misuse of the public declaration due to not understanding the scoping of variables in VFP.


Hey, Jim.

You're right, of course. Those don't need to be PUBLIC. Technically, they don't need to be declared at all the program will still work the same way.

Amusingly, we have had this conversation before. Probably about 10 years ago! I think I disagreed with you about some point or another, but it was purely academic and had no bearing on real applications.
Previous
Reply
Map
View

Click here to load this message in the networking platform