Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Application Object Best Practices
Message
De
25/07/2011 04:01:48
Dragan Nedeljkovich
Now officially retired
Zrenjanin, Serbia
 
 
À
24/07/2011 23:37:01
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MySQL
Application:
Desktop
Divers
Thread ID:
01519029
Message ID:
01519040
Vues:
90
>Naomi,
>
>Thanks for your reply Naomi. Which do you use?

The difference in speed between these is marginal - whether Fox will have to find the variable or the member of the global variable. What matters a lot is the speed of development and the interdependence of these global objects.

Speed of development: it mostly depends on how your mind works. Is it easier for you to remember which member of oApp does this or that, or what's the name of the independent object doing it? Are there other public singleton objects which aren't members of oApp that you may need to call (in which case you need to remember which are separate objects and which are members of oApp)?

I've also seen a mixed approach, where you do oApp.GetHandle(), but oApp's GetHandle method has only one line:

return this.oConn.GetHandle()

i.e. it delegates the calls to its members. It may be some work to write these little calls, but it may be worth it.

The interdependence is a tougher one, but it can bite you whichever way you go. When your app starts up, in which order do you instantiate your global objects, or in which order do you add them to oApp? Also, while they instantiate, do they call oApp.SomeMethod()? oApp variable doesn't have a value until oApp.init() completes, so you can't call any of oApp's methods (except as this.parent.SomeMethod(), but then you can't instantiate such objects as standalone). They may also require help from other global objects (for example, you may require translated strings, so you should call oTran.Translate(this.caption)... or oApp.oTran.Translate(this.caption), but oTran may not exist yet. It can get quite tangled up.

The solution I found to have the fewest problems is to instantiate these global service objects independently, then to add them to oApp as properties. And also to have them use none of the oApp's code while they instantiate. If needed, they can do that later.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform