views:

25

answers:

3

I recently found out that having null initializer for objects are an overhead from http://www.codinghorror.com/blog/archives/000343.html I have a huge C# codebase where in lots of such initializations are made,i want to know if there is any free plug in to help me replace it.I tried to search on net but no free plug ins:(

+1  A: 

Have you identified that these null initializations are creating a performance hit to your application? I wouldn't bother trying to fix something that isn't really a problem (not saying it isn't, just that I am skeptical).

Andrew Hare
Yes i did,If you go on debugging, the null assignments are also executed.As well as the link what i have given states the performance impact.
Ravisha
A: 

Jetbrains's Resharper can do this and much more. It also employs system wide analysis that you can use it to find faults like these. Also it has a code clean up feature which can actually remove all unnecessarily initializations automatically if configured to do so.

Chris Marisic
FYI it's not free but it's the most important money you could spend on your development career for how cheap it is, it does have a free trial though. If you goto http://web2asp.net/2009/09/resharper-discount-and-extended-trial.html you can get a 60 day trial code instead of 30.
Chris Marisic
R# can do this, but saying it's "the most important money you could spend on your development career" is 100% subjective! R# *can* be a useful tool, but it's just that -- a tool. If you don't understand why it's telling you to do (or not do) something you haven't gained anything and you become dependent upon the tool and don't know how to do things any other way.
Scott Dorman
The reason I said it was the most important money you can spend is from resharper-fu letting you save possibly 100s of hours per year on trivial coding and swinging around the solution explorer.
Chris Marisic
+1  A: 

This won't necessarily help you automatically fix them, but if you install the standalone FxCop 1.36, you can turn on just rule CA1805, which will find all of the places you are initializng unnecessarily.

(This rule is not available as part of the built-in Code Analysis rules in Visual Studio.)

Scott Dorman
Thanks scot +1 for that i have been using fxCop but was not aware of this rule.Thanks for the help:)
Ravisha