CodeRush Review Part 2


Continuing my review of CR…

In my first posting I gave an overview of some of the main differences between CR and CRX. I want to touch upon some of the other features that I didn’t mention in my last post, as well as give an update on how I’m finding using CR.

Code Templates

These can be described as code snippets on speed. If you don’t use snippets, you probably aren’t going to use these. If, on the other hand, you do use snippets, you’ll probably want to try these out. Code Templates are like snippets insofar as they expand a few characters into a code block e.g. “c” will expand into a class with a default constructor, and put the cursor over the class name.

Templates are powerful as they are context aware, so the above example will not fire if you’re in the middle of a method etc.. You can also chain them up e.g. “ai” will create a private auto-implemented property of type Int (a = auto implemented property; i = int). You can read more here to see just how powerful and flexible this system is; here’s a combination which creates a public generic property collection:

image

becomes

image

Nice. There are two caveats with this system, however.

Firstly, you need to invest some time and effort in learning how to use these to get the most benefit – you need to first learn the shortcuts – which you can do slowly e.g. one a day. But more than that, you need to change the way you declare some things e.g. consider the following declaration:

protected int MyIntProperty { get; set; }

With CodeRush, you would not type “protected” first – instead, you would: –

  1. Type the appropriate code template (“ai”)
  2. Press space
  3. Enter the name of the property
  4. Then use ALT + down to change the accessor from private to protected. You cannot simply type protected first and then ai as CodeRush does not understand the context and does not fire the template.
    Secondly, and more importantly, code templates sometimes badly get in your way. Example: You want to get a count of all football teams names starting with the letter “A”. You start typing the following: –

image

“f” will be your lambda expression variable. You press space with the intention of next typing “=>”. However, at this point, CodeRush jumps in and using the code template system, replaces “f” with false:

image

Obviously, not what you want! So, you delete the last four characters and hit space so you can put in your =>, only for CR to jump in again… and again. This is extremely annoying; I’ve in fact have ended up using the letter x for such occasions as this is a “safe” character that CR won’t swallow up.

Another example is when you’re typing and VS intellisense pops up to help you.

image

You can normally now press Space and VS2010 will select footballTeams for you automatically. CodeRush unfortunately overrides this, and replaces it with a “for loop” template!

image

What’s extremely frustrating is that the intellisense says footballTeams, but when you press space, you get something completely different. This is a classic example of a feature “taking over” VS and making you change your way of working simply to “live with” that feature, rather than supporting you when you need it. To work around this, I now have to type a few more characters to avoid hitting a CR template – or press Enter instead of Space. Again, having to change how I work.

Code Templates are a really powerful feature (if a little bit of a black art), that if you invest the time in, will pay off quickly. I just wish it didn’t get in the way so much when you didn’t want it.

CodeRush in general

Well, I uninstalled CR and re-installed CRX for a day or two to see how I found going back. I didn’t mind it so much – whether that’s a testament to CRX or simply because I haven’t learnt enough of the power features of CR, I don’t know. I did miss some features, though e.g. the extra refactorings and the IDE enhancements.

I’m still not using the full set of CR features – for example, the unit test runner and the code analysis are still not in use for me, and I’m still trying to understanding exactly how the intellisense enhancements work – but I’m growing more and more used to it now.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s