>>>That does not mean use every tool. Name one time where public is the most desirable.
>>goApp.
>
>I wonder if that is necessary to declare goApp as PUBLIC. Private would work as well, when
>goApp is instantiated in the main.prg before READ EVENTS, at least that's what I'm doing now.
It has the same effect as being PUBLIC when created from the top level program. Many designs do not put goApp creation in MAIN.PRG, but in a called class or procedure.
A couple other reasons to use PUBLIC variables are:
(1) To prevent the requirement of passing "constant" parameters (that don't change during the course of the repeatedly called function (as in recursion), but are dynamic based on the startup / runtime environment when called)
(2) To prevent the need for initializing variables within a oft / repeatedly called function
Visual FreePro bypasses #2 by a new
LOCAL PERSIST keyword, which retains the prior value on subsequent function calls by that thread.
See:
http://www.visual-freepro.org/wiki/index.php/VXB%2B%2B#LOCAL_PERSIST_Variables