Tuesday, August 25, 2009

Why do I find CodeRush so indispensable?

 

I recently said “CodeRush has become an integral part of my workflow.”
and was asked by Braden Powers … “Do you have a blog post or something that explains why??”

I realized that I didn’t, and so here it is…

It comes down to the fact that I use certain facilities provided by CodeRush so often and without even thinking, that without CodeRush present, I end up spending several seconds staring at the screen wondering why some series of keystrokes isn’t doing what I think it should be.

Why should I ever be in such a situation. Well there are a couple of reasons.

  • Some of my colleagues have PCs that frankly cannot cope with Studio, so their chances of being able to cope with *any* addin are nil :( Using such a PC is sometimes unavoidable.
  • Sometimes I get caught on the hop. Between versions as it were. I have received a link to a beta or daily build of CodeRush and have been caught having already uninstalled my previous version and not yet having installed the new version. At this point it’s amazing how the universe almost always arranges a phone call to distract me… after which I forget that studio doesn’t currently have CodeRush.

So which facilities do I find to be most useful? Which ones to I use so often that I honestly forget that they are not a part of studio?

The answer is hard to define explicitly without currently being in one of the above scenarios but I will try.

Essentially the most used functions for me are those that are accessible from the CodeRush SmartTag menu. The Refactorings and the Code Providers.

Now between these 2 categories there are 225 separate functions. Obviously I don’t use all of these on a daily basis. If I were to be presented with the entire list every time I invoked the SmartTag, then I would go absolutely insane and dropkick CodeRush in a heartbeat.

CodeRush manages to provide a wonderfully intuitive interface here. Each Refactoring and Code Provider is intelligent enough to know if it is suited to your current context.

  • The Rename refactoring simply isn’t available if your caret is on a language keyword.
  • The Declare Class Code Provider isn’t available, unless the element under the caret is not currently declared and could potentially be a class.

This means that my one keystroke (I’ve rebound the CodeRush/Refactor key to ALT+1), I’m never presented with more than 5-8 options to pick from.

Next add to that, the fact that CodeRush moves the available items up and down on the menu based on your usage of those items. Constantly re-evaluating how far each should sit from the top of the menu.

Additionally, If CodeRush feels that there’s only 1 function which makes sense given the current context, then you can elect to have CodeRush not even show you the menu, but to move straight on to performing said function. So there’s even less for you to have to do.

ok Enough fluff… Which items do I use so often as to make Studio unusable without them

Note this is just my personal list.. CodeRush has much much more and these simply represent those facilities, whose absence actively slows me down.

First there are the Refactorings:

    • Rename
    • Extract Local
    • Extract Method
    • Extract Property
    • Inline Temp

I cannot stress enough how useful the above 5 Refactorings are in writing any code.

The ability to properly shape a solution as you go is phenomenal. I mean seriously… When you have to nail 2 bits of wood together … Do you use a rock or a proper tool like a hammer?

…Then there are the Code Providers

    • Declare Local
    • Declare Method
      • With parameters all in place based on your usage.
    • Declare Property
    • Declare Field With Initializer
      • Create a suitably named field of the correct type and assign the parameter to the field.
    • …and many more

…all available with a single keystroke (Alt+1 in my case)

Prototyping code has never been this easy

After this we are on to navigation:

  • Navigation
    • TabToNextReference
      • Place your caret on a variable and hit tab. CodeRush immediately underlines all references to this variable on the page and jumps to the next reference in the sequence. It should be noted that the “sequence” covers all references in your entire solution
    • References Tool Window(Shift F12)
      • The References tool window collates all references to any variable of your choice in a single location allowing you to seamlessly skip from one to another.

I feel I should also add add a quick section on the templating system here. I don’t use these nearly as much as I use the SmartTag facilities but it would be hard to since I’m sometimes hitting the CodeRush/Refactor key what seems like every 30 seconds or so.

So some of the template I use more than any others are:

  • Templates
    • Property declaration (pi, ps, pd8 etc)
      • Create properties of various types, with or without backing store, in only  couple of keystrokes.
    • ReadOnly Property declaration (ri, rs, rd8 etc)
      • As above but without the setters
    • Method Declaration (mi, ms, md8)
      • Same again but with methods.
    • Create Constructor (cc)
      • Generates a Constructor which takes various parameters based on your selection of any of the fields supported by the class.

Now It should be pointed out that prototyping any class is now insanely easy

c<space> – Class is created
vs<space>FirstName
vs<space>LastName
vi<space>Age

vi<space>GolfPar
4 Fields are now Created
cc<space><Enter> Constructor created
The constructor takes 4 parameters which are used to populate the fields.
Oh yeah and Readonly properties have been created to expose your fields. All of this is Totally configurable.

The final reason I can’t code without CodeRush is it’s extensibility. When I need something that CodeRush doesn’t have, I use it to create what I need using the DXCore plugin platform.

Checkout what others in the community have done with this amazing platform: Seriously check these out.


3 comments:

Joe Hendricks said...

Fun to see someone's else's fav cr shortcuts! I'd be dead without b[space] for brackets and also the XAF xps[space] style XAF property shortcuts

Rory said...

Yup... B[space] does me no good as I code in VB.Net and i have yet to touch XAF for anything as we have a (Rather complicated) custom DAL already.

Gary said...

Rory, shame you are not using XAF too. Imagine prototyping that class of yours and then, automagically, having a winform app, a webform app, and the database scaffolded for you!