Today I did what I should have done a lot while ago.  I watched the Jedi Coding Demo and installed JetBrain’s ReSharper - The Most Intelligent Add-In To Visual Studio about 30 seconds later. Finally…

After launching VS2008, R# 4.0 Beta asked me a couple configuration-preference-type questions and then I completely stomped on my code until I could recognize it no more.  (Did I mention the full source tree was already imagecommitted to source control?)  

I played with R# for well over an hour as anonymous delegates became lambda expressions1, object instantiation plus a number of property sets were rolled up into an object initializer2, if statements were inverted, switches became if-else statements, foreachs became to-fors, unused methods were removed, ternary operators were introduced, classes were moved into new files, namespaces were updated and on and on and on and back again.

I know I’ve only brushed the surfaces of what R# can do (3.1 feature list, 4.0 beta feature list,) but knowing R# offers far more than a ridiculous number of refactoring shortcuts, I can’t hardly wait to start using it as I write new code. 

One might consider this recommendation premature, but I encourage you to give ReSharper 4.0 Beta a whirl especially if you are new to Visual Studio 2008 and C# 3.* since R# essentially provides you with a painless primer.  (Can’t get your head around Lambdas?  ReSharper 4.0 will create such an expression for you.) It is a quick download and install and it takes only a few minutes to feel the power of the ALT+ENTER keystroke. 

I hope the Add-in makes coding fun enough to make you giggle.

 

Example Refactor 1

private bool IsAliased()
{
    var computer = computerList.Find(delegate(Computer c)
        { return c.ID == RegistryHelper.MachineID; });
    return (computer.Name != computer.Alias);
}

became

private bool IsAliased()
{
    var computer = computerList.Find(c => c.ID == RegistryHelper.MachineID);
    return (computer.Name != computer.Alias);
}
Example Refactor 2
Notification notification = new Notification();
notification.Message = "Message 1";
notification.Title= true;

became

Notification notification =
    new Notification { Message = "Message 1", Title = true };
 
 

kick it on DotNetKicks.com

Leave a Reply

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>