Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Losing Focus
Message
 
À
10/11/2001 10:39:53
Steven Dyke
Safran Seats USA
Texas, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
00580131
Message ID:
00580149
Vues:
19
>Cetin,
>
>Do I just give the value of my parameter to the property? What advatage is this?

Steve,

I am sure Cetin will answer you from his perspective, but let me give you some insignt as to why public variables are a bad idea.

The ONLY reason for a variable to be public is for it to live beyond the method or procedure that creates it. This, by nature, means that some code is going to use that variabel when it has no control over the variable's creation or assignment. This si a poor design as it is pen to all kinds of problems.

Second, you cannot declare a variable public if it already exists, so the second time you run your form you will get an error at the public declaration.

Using a property is better because the property belongs to teh object. A public variabel is flosting around in memory not belonging to anything and possibly stepping on other things.

Imagine a team of programmers working on a project, you create a public variable named Number. The another programmer working on another part of the app needs a private variable and he uses the name Number, but he is now using your public variable totally unknown to him because you created the public var.

Using a property of an object is better because the property is totally contained within the object and doesn't effect any other code anywhere.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform