As I describe in the Golden Rule #2, refactoring is a first class citizen of an agile software development process. However refactoring can be painful without appropriate tooling. I have been using the refactoring tools included in Visual Studio since version 2005. This was until I tried and adopted ReSharper.
Visual studio provides us since version 2005 with great refactoring tools. However you start to see limits of these embedded tools once you start large refactoring work involving multiple projects and cross references. I recently started the first refactoring phase of a large project I am working on at the moment. After a first half through, I decided on trying the ReSharper tool. And this was the best choice I possibly could have done! For information I am talking here of ReSharper version 4.1, and I am developing on Visual Studio 2008 SP1. So here is my feedback on the tool:
First of all, I must say that ReSharper is amazingly well integrated into Visual Studio, as you will see in the snapshots later. Very easy to install and then fully integrated into Visual Studio.
Then I should clarify that ReSharper is more than just a refactoring tool. It includes tools for code analysis, coding assistance, code cleanup, code generation, obviously refactoring and even more… I haven't tried all the included tools yet but I will say a word about code analysis and coding assistance. ReSharper is doing some things that were intended by FxCop (now included in Visual Studio as code analysis), but in a much better way. FxCop was an attempt to guide developers toward writing clean code and following best practices. But it was IMHO a failed attempt, and FxCop was perceived by the developers more as a hassle than real help… Those who have tried the tool can understand what I mean. ReSharper has another very impressive approach to deal with code analysis and gives to the developer hints and advices directly on the source code view! And it is presented as hints rather that error messages. It might seem a detail but it makes a huge difference! Well I guess that FxCop provides many more rules than ReSharper and is not intended for the same purpose, but the ReSharper concept could maybe be used for competing with the Visual Studio code analysis.
Things I experienced are still missing in ReSharper are: renaming in XOML files for WF workflows. And I am not sure yet how renaming works globally with XML configuration files… So if you use dependency injection and configuration in XML then you might have to handle the renaming by hand. Therefore this is one advantage of configuration the DI cotainer dependencies though code versus XML, but that's out of scope here… Another thing that does not properly support renaming is data source definition files.
I will now give some examples of ReSharper features I found interesting while refactoring my project.
First example is the nice way ReSharper highlights (light grey) the unused or redundant parts of your code and propose hints and operation to remove it. In this example, ReSharper proposes you to simplify your code by removing a redundant qualifier:
And in the next example, ReSharper proposes an option to clean up the using directives by removing the unused ones. By the way you can automate this cleaning process on the whole code:
ReSharper also highlights potential runtime problems like in next example where you get the hint that you might get an exception from an API call. Up to you then to judge if your need to add error handling code:
One great feature is that ReSharper allows you to rename namespaces or portion of namespaces. This is something very useful as reorganizing namespaces is a very common refactoring scenario. I have validated that this refactoring works amazingly well, included across multiple projects:
ReSharper provides an improved way to navigate usage of method, or class:
Please note that ReSharper is able to navigate usages in comments! It is also able to rename into comments. So if you rename a class, you can ask ReSharper to rename the name of the class when it is used in comments!
Other example: ReSharper gives you hints to clean your code (more than hints: it is able to do the work for you):
Improved Intellisence, with here an example of highlighting obsolete methods:
A last example: when a reference is missing, ReSharper highlights it for you and gives you the option to add the missing reference. Well Visual Studio does it too. But ReSharper does it a more visible and accessible way that the very little underscore you need to click with Visual Studio:
To conclude I was really convinced by the tool which was of great help for my refactoring phase! And I am discovering more and more functionalities every day…
Comments
You can follow this conversation by subscribing to the comment feed for this post.