Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Extending the scope of a variable
Message
 
 
À
22/05/2009 15:14:00
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires
Versions des environnements
Environment:
C# 2.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Divers
Thread ID:
01401587
Message ID:
01401598
Vues:
36
>Why not? What make you think otherwise?

Just looking at the logic of the program.

>
>I don't agree with adding a public property to the class. Why pollute the class with something that is used as a local variable? Public on top of that.
>
>I understand that you want to limit the number of object instanciated, but you increase the chance of a side-effect. When recycling an old object, you need to be sure to reset all the properties to their original values. You may write your code now to do that, but if you (or someone else) add a new property to the class and forget to reinitialize this new property in the code, you may get a undesired side-effect. Much simplier to let the garbage collector do his job.
>

The class (cSite) may have a public method to reset all properties to their default values. In this case we may re-use the same object.
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform