AZURE update

November 1, 2008

Greetings

I’ve only seen my very simple project work twice. The first time was when I first built it; the 2nd time was some random success. Typically, it just times out after 3 minutes.

I’m setting this aside from now. This has inspired me on a project I’ve often talked about doing but never took on. So, I’m working on that now. I tend to start a lot of stuff and never finish it. This may be such a project, but at least for the moment, I’m motivated, and I’m working hard on it.

I’m going to use SQLCE as the default data store for the project. I haven’t used it before, so it’ll be neat. (Of couse, you can swap it out with any data store you want, but it’ll be ready to run out of the box because of CE)

Advertisements

Resharper: "Use implicitly typed local variable declaration"

November 1, 2008

I’ve been using Reshaper for a couple weeks now. I like it a lot. When I was given the option to get a license for this, I responded that I would rather Code Rush. Afterall, I write more code than I refactor.

That ended up being an over simplification, though. Resharper has lots of great goodies in it. Though I would still like Code Rush, Reshaper is great all by itself. I learn to appreciate it more any day.

Except for the “Use implicitly typed local variable declaration” hint.

As an example, I have this line of code:

ServiceDescription description = attribute as ServiceDescription;

the type, ServiceDescription, is underlined with the fore-mentioned hint. Basically, its telling me to define the type as VAR and let the compiler figure it out for me.

I’m not a fan of that suggestion at all. If I know what type it is, then I want to specify the type. I don’t need the compiler to figure it out for me. If I end up specifying a less than optimistic type (ie: should’ve used XmlReader instead of XmlTextReader), then Resharper or FxCop will let me know, and I’ll learn from my mistake rather than just let the compiler do its voodoo for me.

However, I don’t want to be irrational and just blindly shut off the hint. I wanted to find the justification for that hint, so I started poking around. It seems that there are 2 prevailing schools of though on this: Those that think you should use it for everything, and those that think you should only use it for anonymous types.

After reading a few different things, I have committed to my opinion expressed above: If you don’t know what type it will be (because its anonymous), the use var. Otherwise, specify the type.

A guy from resharper justifies it here:

http://resharper.blogspot.com/2008/03/varification-using-implicitly-typed.html

While interesting, it doesn’t sell me. Some comments on some bullets:
– Its is required to expres variables of anonymous type – no kidding. that’s why it was invented.
– It induces better naming for local variables – that’s putting a square peg in a circle hole. Its handholding at best. If you name you’re variable CURRENT then its scope should be so small as to always remain obvious what it is. If it isn’t obvious, then you named it wrong, and declaring it of type var isn’t going to make you name it any better.
– It induces variable initialization. – Again, I don’t need VAR to force me to do that.
– It removes code noise. – Maybe. I’d like to see some samples before I buy it.
– It doesn’t require a using directive – so what? Are using directives troublesome to anyone? Heck, Resharper puts it in for you. If you don’t have resharper, then CONTROL+. will put it in for you.

That’s my story.