Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Public Variables or Object Properties
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Divers
Thread ID:
00510878
Message ID:
00669146
Vues:
25
>Kev,
>
>Here's why.
>
>The wider the scoping of a variable the more likely there will be a conflict with something. Therefore, no variable should ever be scoped wider than is necessary for it to function appropriately.
>
>A private variable declared in the top level program is visible to every program and emthod called from that one (global to the application). It is also automatically cleaned up when the app ends.
>
>A public is visible to the entire application but it is NOT cleaned up when the app ends. It hangs around and perhaps causes problems with other apps. Even if you release it at your apps end you may still have problems. Imagine the following;
>
>app one: main object name is oApp and it is PUBLIC, this app is a contact manager
>
>app two: main object name is oApp and it is public. This is an accounting app.
>
>App one is running.
>
>App two is started.
>
>App one tries to call a method of main object named DoSetup to set up for a new salesperson. However since app two has started the variable named oApp is now the accouting main object and it has a method named DoSetup that sets up data files for a new company. Think about it ...
>
>Conclusion PROPERTIES of objects are the best because they belong to the objects, LOCALS are the next best because they belong to a particular procedure or method, PRIVATES are the second worst because they are visible to called routines, and PUBLICS are the absolute wiorst because they hang around even if the creating code has finished.

What do you do when you have a value that needs to be seen throughout an app(or object) but is too large to be a value of a property?
Eric Kleeman - EDS Consulting Services
MCP Visual FoxPro
MCSD C#.NET
Hua Hin Thailand
Los Angeles California
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform