Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Grid
Message
De
30/12/1999 23:41:50
 
 
À
30/12/1999 19:54:11
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Titre:
Re: Grid
Divers
Thread ID:
00310213
Message ID:
00310821
Vues:
19
Just MHO:

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.

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.

This is problem in almost any programming language and the main idea is to never (or as seldom as possible) modify a variable (from a higher level) that was not passed as param by reference. So, pass it by reference. The function becomes independant from the rest of the code by doing so.

Vlad

>As to object references, I'll bite: If I am doing oObj=NEWOBJECT("something","something") and I am doing this in some method somewhere but want oObj referenced everywhere, what's wrong with PUBLIC oObj? Or do I have my head up my butt? (a common occurence lately).
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform