July 9, 2008

CodeRush with Refactor! Pro vs ReSharper

Filed under: Tools

Every developer knows already, that Visual Studio is not sufficient enough for code writing. There are lots of Add-ons which are able to improve daily work to significant manner. I use such tools everyday as : ViEmu, GhostDoc and Smart Paster. I used also CodeRush + Refactor! Pro from 1.5 year, but from moment of appearance of ReSharper 4.0 public beta versions, I decided to take closer look to this tool.

After several months of using ReSharper, I’ll try to make a small comparison of both products functions in range I used most often.

Some images are linked with external animations.

Refactoring

Both tool contain similar amount and quality of refactoring functionality.  There is a small inconvenience of mouse using during refactoring in ReSharper. Just keyboard usage is enough for CodeRush using.

Here is simple example of method signature change

R#

 

CR

Code generation

Both tools have sound and weak parts in code generation. Better possibilities of creating more intelligent code templates are in CodeRush than on ReSharper. It’s all about definition of conditions when and which template can be generated. In CodeRush, you can define that writing ‘c’ and then ’space’ pressing will generate "case" keyword in "switch" statement but in "foreach" loop it will generate "continue" keyword. ReSharper is less flexible in defining such conditions. In fact, I can live without it. The bigger problem is that CodeRush cannot allow you to hare these templates among other users. Templates are kept in user local folders and there is only export and import function. ReSharper can share templates in many ways:

  • per system
  • per user
  • per solution
  • per personal solution
  • defined in external file - it helps to maintain corporate range templates

ReSharper has one more kind of template, which CodeRush does no have it at all, file template.

We can treat unit tests as a API sketch, as as draft for defining how our class can be used. To do that we just write name of methods and proprieties which actually doesn’t exist yet. Both tools will generate proper stubs for them.

ReSharper isn’t sometimes as intuitive as it would be. That’s why I suggest to take a simple  look to documentation before using it, if you don’t want to be surprised. Some day I wanted to create some overloads for a method. In CodeRush, you can place cursor on method name, press Ctrl + `, and you will see how easy is to create overloads by using "space" and "left, right arrows"…

… in ReSharper you need to select method parameters and then press Alt+Enter …

In that situation you cannot make and overload  for example removing first and third method parameter.

Generating additional code based on existing code is solved in two ways. Example of generating properties based on existing fields.In ReSharper, you need to press Alt + Insert and then choose fields …

CodeRush has SmartPaste i SmartCopy. In that case it is enough to copy field and paste it. That’s what developers love the most ;) copy & paste :).

This way is not good enough if we have a bunch of fields which are not grouped together and are different types. In that situation SmartPaste doesn’t work too good, ReSharper’s way doesn’t look nicer but work better.

Additional ReSharper functionalists …

… which there is lack of in CodeRush.

Code analysis

ReSharper analyses code all the time and can point out errors even before compiler will do that. Additionally suggest us how to better write a code.

But it has price. This functionality needs more memory from our machine and can slow down Visual Studio when you are writing code in DSL-like manner. Many methods or properties connected in one logical line like in NBehave testing.

More about code analysis

Code reordering and formatting

Java users had a Jalopy, C# users had nothing until ReShareper came out. In my opinion it is the best tool for automatically C# code formatting in the market. It is fully configurable and configuration can be shared among other developers. This will allow us to make our own corporate standard of code formatting.

More about code reordering and formatting

ToDo Explorer

Visual Studio allows us to insert special tags in comment such us TODO, FIX ,HACK and so on. But it cannot make a summary list of them from whole solutions. ReSharper can do that.

Unit Testing

Now we have all in one place. Running, debugging and profiling tests also. ReSharper ca run NUnit test only by default. But there is some plug-ins which integrate TestRunner with other frameworks.

kick it on DotNetKicks.com

Get free blog up and running in minutes with Blogsome | Theme designs available here