Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Initializing your variables when you define them
Message
From
15/02/2009 10:18:09
 
 
To
15/02/2009 10:14:08
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, United States
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
C# 3.0
Miscellaneous
Thread ID:
01381858
Message ID:
01381884
Views:
28
>>>Do you do it? I've read in one Microsoft Press book not to if you don't need to, but read in another that you should. If you check the setting to treat all warnings as error in your project more than likely at some point you will be nagged about it if you don't.
>>
>>I think there used to be a performance hit, but with the latest version of dotnet, it is now optimized so it doesn't matter (or so I read somewhere and I cannot find it now). I haven't seen any benchmark tests on the latest version though that demonstrates either way.
>>
>>http://www.codinghorror.com/blog/archives/000343.html
>>
>>and the opposite view:
>>
>>http://visualstudiomagazine.com/columns/article.aspx?editorialsid=2377
>>
>>and then there is this problem (I recommend you read this; it's short too):
>>
>>http://blogs.msdn.com/abhinaba/archive/2005/11/08/490248.aspx
>>
>>and then perhaps it should be mentioned that notification depends on the level you set in the compiler.
>>
>>for class member variables, I tend to follow the field intializer example here:
>>
>>http://stackoverflow.com/questions/298183/c-member-variable-initialization-best-practice
>>
>>You might find this interesting, but it really has to do with optimizations that the compiler should be doing:
>>
>>http://akashkava.com/blog/?p=18
>
>Wow. I'll read those all when I get a chance. Thanks!

This is something that was researched and caused many discussions (with folks taking both sides) in my learning dotnet during the past couple of years. In a shop of developers, it can fall into the category of 'internal standards' when folks are adament that their way is the best.
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform