Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Extending the scope of a variable
Message
From
22/05/2009 15:14:00
 
General information
Forum:
ASP.NET
Category:
Forms
Environment versions
Environment:
C# 2.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Miscellaneous
Thread ID:
01401587
Message ID:
01401593
Views:
34
Why not? What make you think otherwise?

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.

>I don't think the objective is to create a variable in each read.
>
>Alternatively we can create a public property site in the class declaration.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform