>If a var must be public (ie any other piece of code should see it), than there's nothing wrong with making it PUBLIC. If, by any chance, you're not sure it must be so public, declare it PRIVATE somewhere at the beginning of the app and initialize it there.
Vlad,
So when is a var required to be public?
>As for your example: if you initialize oObj somewhere in a method but it should be available from everywhere, your code will use a lot of IF TYPE("oObj") etc because you have to test it everytime you want to use it. This looks like a design problem. Anyway, even if oObj is a PUBLIC var, then it's better to declare it as PUBLIC at the main prg level and pass it by reference to the method that initializes it. Doing so, you have the felxibility to change your code and to do it more safe and easier.
It is never necessary to declare a variable public in the main start up prg of an app. A private is globally visible to the entire application.
I have only one public declaration in my systems. That is a debugging feature of my framework. I can run my application in VFP without a READ EVENTS so I can use the command window, debugger, and editors to work on the app while it is running.
So my Start.PRG has this kind of code in it;
LPARAMETERS plDevMode
...
IF plDevMode
RELEASE oApp
PUBLIC oApp
ELSE
PRIVATE oApp
ENDIF
...
oApp = CreateObject("AppMgr")
IF NOT plDevMode
READ EVENTS
ENDIF
That one var has to be public or else the appmgr would go out of scope when Start returned to the command window.