Goodbye ReSharper, hello Refactor! Pro

I was a little split on tools tonight. Like most of us, we spend most of our waking day inside an IDE writing and designing so we want the best use of our tools that we use. I’m always looking for ways to better my codebase and refactoring is a technique that I employ all the time. Little tweaks make things easier to read and generally make my code more maintainable. However it’s always hard to tell what the right refactoring is and when it should be applied.

I use ReSharper from JetBrains, but lately they’ve been a little lax with updates. Their VS2005 product isn’t final yet, many people (including myself) have tried it but then uninstalled it when your stable IDE becomes unstable. So I thought about looking at other options. Scott Hanselman is big fan of CodeRush and the DevExpress products and they have a refactoring tool called Refactor! Pro (and hey, if Scott likes it then it must be good right?).

Refactor! Pro has a nice set of features that take it above what ReSharper offers. It’s the same price point ($99USD) so anything it offers above ReSharper is just icing on the cake. Here’s a few that I like which gave me the swing vote for the product.

There’s a nice little animation that is displayed when you hover over a return statement that shows where it returns to (makes for visibility of the code you’re about to skip that much more potent).

Here’s one that I’m mixed on using, Inline Temp (or mixed on, using Inline Temp if you prefer). The idea is that instead of doing this:

  101                 int cultureId = Thread.CurrentThread.CurrentUICulture.LCID;

  102                 if (string.Empty != LayoutsDir)

  103                 {

  104                     if (string.Empty != StyleSheet)

  105                     {

  106                         // Both LayoutsDir and StyleSheet specified

  107                         styleLink = string.Format(

  108                             "<link rel=\"stylesheet\" type=\"text/css\" href=\"/_layouts/{0}/styles/{1}/{2}\">",

  109                             cultureId.ToString(), LayoutsDir, StyleSheet);

  110                     }

  111                     else

  112                     {

  113                         // LayoutsDir but no stylesheet (kind of useless though)

  114                         styleLink = string.Format(

  115                             "<link rel=\"stylesheet\" type=\"text/css\" href=\"/_layouts/{0}/styles/{1}\">",

  116                             cultureId.ToString(), LayoutsDir);

  117                     }

  118                 }

You remove the introduction of the cultureId variable and do this:

  101                 if (string.Empty != LayoutsDir)

  102                 {

  103                     if (string.Empty != StyleSheet)

  104                     {

  105                         // Both LayoutsDir and StyleSheet specified

  106                         styleLink = string.Format(

  107                             "<link rel=\"stylesheet\" type=\"text/css\" href=\"/_layouts/{0}/styles/{1}/{2}\">",

  108                             Thread.CurrentThread.CurrentUICulture.LCID.ToString(), LayoutsDir, StyleSheet);

  109                     }

  110                     else

  111                     {

  112                         // LayoutsDir but no stylesheet (kind of useless though)

  113                         styleLink = string.Format(

  114                             "<link rel=\"stylesheet\" type=\"text/css\" href=\"/_layouts/{0}/styles/{1}\">",

  115                             Thread.CurrentThread.CurrentUICulture.LCID.ToString(), LayoutsDir);

  116                     }

  117                 }

Personally I think creating a variable once and using it (as long as the variable has a good name) works better and is it just me or isn’t calling a method 3 times rather than referencing a variable is more expensive? Okay, we’re talking about milliseconds here, but sometimes every line of code counts.

When you select a line there are different options. Here it’s asking me if I want to do an Extract Method refactoring, using the HtmlWriter parameter and a local variable as parameters to the new method. The arrows show where it’s getting all the info from (and there are additional popups that didn’t get captured like the tooltip explaining the refactoring).

When you hover over strings, you can invoke the Introduce Constant refactoring, replacing that string with the constant value. I always find this a pain as I just naturally type in quoted strings rather than stop, go create a variable, then come back to the point I left. It interrupts the natural flow of things. Some would argue that going back and doing it after the fact takes more time, but again if it’s automated like here then I think it’s faster in the long run.

Finally as you hover over the three little dots Refactor! Pro puts under your variables, methods, and such it creates the pulldown menu (sometimes there are multiple refactorings you can do on a variable) a small tooltip explaining the refactoring. Nice if you don’t know exactly what it will do but also helps for newbies that have never used a certain refactoring before.

A really powerful thing is that you can create your own refactorings and apply them. While the base product supports all the known refactorings out there, this makes the product shelf-life that much longer as new ideas are discovered or even if you do something on a regular basis, you could build your own here. Yes, it’s like a glorified macro tool that is already built into Visual Studio but it has some smarts and looks like it could be powerful (especially if there’s a way to get new refactorings from the community at large).

I think the key thing is that it supports both VS2003 and VS2005 with the same product. This is key for me as I have dozens of tools that I buy, I have to be a little picky over what I purchase. With ReSharper I have to purchase two separate SKUs and pay for it. Refactor! Pro seems to offer both of my IDEs the same tool for the same price. Kudos to them as I like this in any product (and probably because I’m miffed that I now have to buy an XBox 360 version of my Burnout Revenge because my XBox version of the same game isn’t compatible with the 360).

There are other advantages and disadvantages. I don’t think Refactor! Pro highlights errors like ReSharper does, but it’s hard to tell (especially when you have both products installed at the same time). Refactor! Pro doesn’t show all refactorings with ones that don’t apply greyed out so the menu is smart and only shows you what’s relevant so I’m not sure the full set of refactorings that it supports, but I’m sure they’re all there (in my testing, it was “Good Enough”). The only big thing which swings me to looking at buying CodeRush as well as Refactor! Pro is the code templates. ReSharper has them built into their product, so you get the refactorings but you can also type in “tcf”, press TAB and get a try/catch/finally block. Refactor! Pro is just about refactoring and doesn’t seem to have this capabilty built-in but if you go the extra step you can buy CodeRush and get that feature (along with the other 10,000 things CodeRush does). Still, it was good enough for me to switch but YMMV.

Also as a note, refactoring is not about tools it’s about understanding when to refactor and apply the right refactorings. Tools can help you and make things quicker for you, but you need to know why you’re doing it. Like a skilled craftsman with a chisel, he can get the job done twice as fast with a plane but he needs to know how to do it first in order to be called a craftsman. Developers are the same and I try to teach people manual refactorings first so a) they know the pain and suffering you go through to refactor manually (it can be tedious sometimes) and b) they know why they’re refactoring and it’s not just a click of a tool to move code around. Only then do I talk to them about tools and how they can get the job done quicker. So learn why you refactor first and the raw mechanics of it, then look at automation to help out.

P.S. why must people put Pro or Advanced or something after their product names? There is no Refactor! Standard product, just Refactor! Pro. Is it a selling gimmick? Maybe I should start creating products with Pro in the name (but not offer a standard version). Must be me but then I’m also still looking for a copy of Microsoft Windows Amatueur edition. I know it’s out there.

There, I think I’ve said the word refactor so much that this blog post will hit the top of Google in a day or two now.

8 Comments

  • Can you explain what is the difference between CodeRush and Refactor Pro ?

  • Did you experience any slow downs in the IDE? When I tried Coderush a year ago, it made the IDE crawl after a while because the codebase wasn't that small (and already chopped up into several solutions). I guess refactoring applications require also the code being parsed completely which can slow down things as well... Also a reason why I found resharper unworkable.



    Btw, you as an MVP can get all devexpress tools for free.

  • Two things:



    1. Refactor! Pro is called that to differentiate it from the one available free to all VS205 users that only works with VB. Pro works with multiple languages and, I believe, has more refactorings.



    2. Refactor! (Pro or otherwise) is a refarctoring tool as the title suggests. Coderush is a tool that assists coding (code completion and many other features).

  • @Frans: I did notice a bit of a slowdown but I had all three products installed. I removed ReSharper and found the load to be okay. The first time was a bit slow, but subsequent loads (even after a reboot) seemed good. The IDE performs fine with it loaded. Thanks for the info about the free product, I'll check into that.

  • The error highlighting of Resharper for me is an incredible time saver, too bad only that the folks at Jetbrain need so much time to make it stable. I must say that for me the latest build (109) for VS2005 is workable in a large solution. Xdevelop also has a product that does error highlighting, but it made just to much mistakes. Just my 2 cents...

  • The VB2005 version is the only free product, although I think Frans might have been offered a complimentary license of our full .NET Subscription as a C# MVP and that would have included CodeRush which includes Refactor!. Contact ClientServices@devexpress.com and they may be able to help.



    The distinction betwen the two products is that Refactor's focus is tweaking existing code. CodeRush is a general accelerant for development, and gives a developer ways to create, visualize and navigate through code more quickly, it also includes Refactor!



    The other difference is that Refactor! was designed to favor discoverability, and CodeRush functionality. Check out the flash movies in my link for some ideas on how you can use CodeRush.

  • &quot;The VB2005 version is the only free product, although I think Frans might have been offered a complimentary license of our full .NET Subscription as a C# MVP and that would have included CodeRush which includes Refactor!.&quot;

    I have access to all devexpress products with the license provided to me by devexpress (thank you for that :)). I'm not sure if this is a C# / VB.NET MVP only license, I would understand why that would be the case :) (so MVP's of other groups would have a limited license)

  • resharper definetely hogs system resources! been a victim before, CodeRush Xpress wins!

Comments have been disabled for this content.