Tuesday, 10 June 2008

The Resharper cult members already know this, but for those who haven't joined yet, version 4.0 released today with VS 2008 support -- huzzah,  huzzah.  No longer able to resist the chanting and promises of eternal coolness I donned my robe and installed my free copy.

I clearly should have joined sooner.  Resharper has already changed my life.  First it pointed that I had redundant overrides  in the control I was working on, which I had really meant to delete.

Then it reminded me about the new implicit type declaration keyword var, so this...

XmlDocument SomeDoc = new XmlDocument();


var SomeDoc = new XmlDocument();

Granted, that's not too exciting, but if your type declaration is something like...

Dictionary<SomeStrangeType,ANamespace.AnotherLongType> SomeDictionary = new Dictionary<SomeStrangeType,ANamespace.AnotherLongType>();

with var it becomes...

var SomeDictionary = new Dictionary<SomeStrangeType,ANamespace.AnotherLongType>();

Then Resharper pointed out something I didn't realize was available in C#, the object intializer?? VB.NET has long had something similar with the With statement (now with object initializer goodness too).  What's nice about this is that it saves repeating the instance name in front of the properties.  So this...

var MenuBinding = new MenuItemBinding();
MenuBinding.DataMember = MenuItemElementName;
MenuBinding.TextField = DisplayTextAttribute;
MenuBinding.NavigateUrlField = NavigationUrlAttribute;
MenuBinding.Depth = Depth;


var MenuBinding = new MenuItemBinding
     DataMember = MenuItemElementName,
     TextField = DisplayTextAttribute,
     NavigateUrlField = NavigationUrlAttribute,
     Depth = Depth

I was staring at this new construct when I realized that -- it shouldn't work. The project I was working on was a Framework 2.0 project and these things were in 3.0 syntax.  But the darn thing compiles and works.  Not even a single warning.  WTF?  It turns out that since 3.0 and 3.5 are based on 2.0, these are simply compiler tricks -- there is nothing fundamentally different about the types.  Here's a blog post that explores in more detail what is happening under the covers.

Not bad for 15 minutes of tooling around.  Guess I am an official member. Where's the Koolaid?

.NET | 2.0 | 3.0 | 3.5 | Resharper
Tuesday, 10 June 2008 22:24:01 (Eastern Standard Time, UTC-05:00)   #     Comments [0]  | 
Monday, 16 April 2007
Spent Saturday getting my geek on at the NOVA (Nothern Virigina to those of you outside of the greater Washington DC area) Code Camp.  The camp was pulled together by Jeffrey Schoolcraft who marshalled a host of volunteers, speakers and contributors to make it a great success.  If you didn't learn at least 10 things you probably slept through all the sessions. Heck, I learned a bunch of things chatting between sessions. Here's a smattering of what I learned.

  • It's time to start learning about WCF (Windows Communication Foundation).  This is going to be the way to build distributed applications going forward, and it seems to get away from some of the headaches of remoting and web services.  Definitely a great plumbing platform that should make it easier to develop apps that span systems.
  •  WPF (Windows Presentation Foundation) is going to be very interesting eventually and even has some cool implementations, but the design tools aren't ahem, mature yet. But WPF will further erode the line between desktop and web apps. Fortunately, XAML should be very familiar to anyone who has been doing ASP.NET development.
  • I really need to get a copy of Resharper for my daily refactoring.
  • There's a better way to search for useful .NET information without having to wade through unrelated results in Google or other search engines. 
  • I was introduced to ELMAH, the library I need to use to replace the hand-rolled exception code I've been lugging around.
  • When ordering pizza for an event the ratio of pepperoni pizzas to cheese pizzas should be between 2:1 and 3:1. Not enough people actually like cheese pizza to make 1:1 a viable ratio.
Also got to meet a lot of people I had only known by name or online.  Not a bad way to spend a Saturday.

.NET | 3.0
Monday, 16 April 2007 09:32:13 (Eastern Standard Time, UTC-05:00)   #     Comments [0]  | 

Theme design by Dean Fiala

Pick a theme: