I know, I know…I should’ve post this weeks ago, but it took me more time due to some personal and business reasons. Anyway, now the article’s here and it’s time to rock the world with with CodeRush and Mark Miller. Enjoyed the movie? I’m sure you did. Let’s see what are we able to do with keyboard, but step by step.
Table of Contents
I’ll skip the installation as it takes just a few click and run the Visual Studio 2008 SP1. After the very first startup (with CodeRush and Refactor! Pro installed) you face up with the following dialog.
The dialog allows you to switch between “New user” or “Expert user” modes and gives you an option to run the tools manually instead at startup.
If you’re a new user of CR, then just accept the predefined settings. As you’ll see later, using “New user” mode will shorten your learning time.
The first two things you’ll notice (once everything is loaded) are:
The DevExpress menu. Trough the menu you can access add-in related windows, configure options and check for updates. However, this menu doesn’t bring any additional functionality to Visual Studio, so you won’t need it many times.
The DXCore Visualize toolbar.
The toolbar contains a set of toggle buttons allowing you to turn of/off the following features:
- Code Issues
- Spell Checker
- Member Icons
- Flow Breaks Indications
- Code Metrics
- Structural Highlighting
- Region Painting
- Right Margin line
- Step Into Member
All of these features (except “Step Into Member” – which is being used in Debug Mode) are related with code editor. I’ll return back to them when writing about Code Issues and Visual Impact.
I think that the most important thing for many developers is Coding Assistance, that’s why I’ll start with that first. As this is a set of categories like templates, refactoring, code issues detection and others, it would be great to put them all under one roof. In CodeRush this is done trough the tool window, like the one bellow.
Moving the caret around the code gives you some tips, as we’ll see that during the review.
Note: this windows is turned of by default, so you need to open it manually by going to “DevExpress\Tool Windows” menu and selecting “CodeRush”.
Now it’s time to put templates under the pressure.
As a developer I want to produce more code in less time, that’s why templates are very important for me. I believe many developers thinks the same. Visual Studio templates are useful, but not as much as I want, so something more powerful would be more than welcomed. I open up the CodeRush window to get some help around the templates. I want to create a Collection<string> property inside my class. As I have no idea how to use templates, I follow CR assistant. Here’s an example of how CR assistant will help me writing my code.
As you can see, it was pretty easy to create property. How about a method? Same technique, just instead of p (as property) I used m (as method). I don’t want to spend a day writing about templates only, so you’ll have to believe me on word, that CR templates truly rocks. I’m impressed with them, especially as it’s possible to use my own classes in them. To do that I needed just to right click on the class I wanted to use in CodeRush templates and click on “Use Type in Templates…”. Great isn’t it? Well there’s one thing that bothers. I didn’t find a way to remove my class from templates. However, this doesn’t change my opinion about CodeRush templates. They’re just awesome.
Refactoring is another important word in developer’s dictionary. I will show just some of the refactorings Refactor! Pro provides. As you can see, list of refactorings is very long, but does that mean we can take full advantage of them? No, unless you find a way to do that. What bothers me in Visual Studio is the way how to execute refactoring. I need to use menu or remember all shortcuts, which is pretty silly. Why we can’t have one keystroke to rule them all? So I went to CR Options hoping to find something to ease my life. After spending a few minutes in “IDE\Shortcuts” section, I found what I was looking for. Ctrl+` is a default hotkey to bring up all possible refactorings under caret position. Yes!
Time to see how refactorings in action. I press the magic hotkey to bring refactorings popup in front. Something I haven’t been used to see before, is a preview showing what each refactoring will do.
Do you like the it? I do and I do from the whole begin. It was a great help to understand what will happen in the code once an action is taken. Moving among possible refactorings will reflect in preview. Here are some of other possible refactorings:
…and another one in VB.NET:
Do you often search for a class or a file in your solution? You want to quickly find all references? I do. And using Visual Studio native support is more or less awkward. CodeRush has answer to that, and that’s a pretty good one.
Quick Navigation: provides you a way to find members and types, by accessibility and scope. Search works very well even on large projects. The most fabulous thing about that is “T-SQL LIKE” search and uppercase search, seen on the image bellow shows.
Holding Ctrl key will give you a preview of selected member (text in blue rectangle).
Quick File Navigation: will allow you to easily find files within the solution. This search is very similar to previous one.
- Jump to menu: This menu allows you to jump to specific part in your code with respect to your current position.
- Tab navigation: This is something you’ll love it. Pressing a Tab key when your beam cursor is on member in the code will highlight all references of current member. Pressing Tab again will move you to next occurrence, while Shift+Tab will navigate you back.
- Uppercase navigation: Another thing I love as well is uppercase navigation. By holding Alt key when using arrow keys left/right will move cursor to previous/next uppercase character in the word. En example of this functionality can be seen on pictures below.
Alt + Left Using Shift key along will give you another option with selection
Show References: Not much to say about it. This is a good looking window, but it doesn’t bring any functionality that’s worth a mention except the preview. It’s UI and performance are way ahead of Visual Studio’s, but it has some deficiencies as well. I really miss a shortcut/hotkey to navigate up and down among the results, just like support for multiple results. Another thing I’d really like to see is support for interface references if class implements an interface. However, we’ll have to wait for that a little bit longer. Maybe someday this will be all implemented, but until then I find this dialog pretty much useless.
Markers: Does it happen to you that you don’t know where you ended up before using “GoToDefinition” a few times? So far Visual Studio’s navigate backward menu served me pretty well, but I hated one thing. Whenever I changed cursor position, a record was added to history. This means that every time I wanted to go back to where I left, I had to go trough long history. I think this should be done more simple. CodeRush provides Markers. Markers allow you to remember current cursor position, so you later return to it very quickly. For easier understanding, imagine markers as a LIFO stack of bookmarks. So how do they works? When you execute “GoToDefinition” action for example a blue triangle is being dropped as you can see on the picture bellow.
When marker is collected a blue circle (like on image above) appears and starts narrowing until it finally hides. I like animation as it catches my attention, so I can know what happened instead of looking around the screen where my beam cursor ended up. Another cool feature about markers is that are heavily used in CodeRush templates. This allows you to quickly jump into another block like in try-catch template.Note: Use Alt+Home shortcut to create your own marker.
Once I ran Visual Studio with CodeRush installed I’ve noticed a vertical bar on the right side of code editor. This bar is visible when code analysis is turned on. So I moved my mouse to the bar and hovered over one of the red lines. A very nice popup jumped up showing what error are present in code.
Moving a cursor to each “notification box” on popup window will give you preview of code where an error has been found. If you click on it, your caret will jump to error location. This “notification boxes” contains some links – suggestions to fix the problem.
All issues are accessible in code editor as well.
So what kind of stuff CA – Code Analysis reports:
Code Analysis provides 120+ code issues detections which is great. However. CR issue detection engine isn’t as good as it looks at first sight. Sometimes it reports false issues and some suggestions need improvements.
Depending on what we’ve seen so far, we can say just WOW! Visual impact in CodeRush is at highest level. No doubt about that. If you don’t believe me, then take a look what’s left for this section:
- Structural Highlighting: gives you great overview in code
- Member Icons: represents type of member (method, property, field, class, …)
If you click on member icon you get the following menu:
Flow breaks: as you can see on the image bellow, addition icons appears in editor. Those icons represents spots in code where flow break is possible. Hovering any of this icons will trigger a nice animation showing you where the code will continue after the break. If you click on it, the caret will jump to that location and a marker will be left in case we need to return back.
- Code Metrics: Those who put some attention to metrics, will love number of metrics CodeRush provides. Some of them are visible in editor…
…and the rest of them are accessible trough metrics window, which can be opened trough “DevExpress\Tool Windows\Metrics” menu.
- Region Painting: Does this reminds you at Visual Basic? Even if I never liked VB at all, I find region painting very useful, especially when code is full regions.
- Spell Checker: is a great addition to CodeRush. Unfortunately it works only in comments, but even that is good help.
- Important Informations: won’t get unnoticed in CodeRush. Some of them are exposed trough additional window which appears in the bottom right corner…
… some of them are OSD text.
Do you write unit tests on a daily basis? If you don’t then it’s time you start it. Those who are writing them, which one do you like the most? Nun it, Mistiest, Mount or unit? Does it even matter? Well maybe for each of us it does, but it certainly doesn’t for CodeRush as it supports al of them. Don’t event know if there’s anything else good out on the market as I’ve been using Mistiest all the time. However. Let’s see what’s the real benefit of CodeRush unit test against native Visual Studio support.
One thing that will catch your attention for sure is a new icon in front of “Test” attributes and at the end of namespace. By clicking on this icon a context menu appears giving us two options to go for it.
So what happens after that? Instead of seeing results in the “Test Results” window, we do seem them straight in the code. This visualization provides better overview which tests need to be run again. Hovering the icon will show you a message, where test has failed.
Ok this way we get great overview in code, but what about overall? CodeRush provides a window name “Unit Test Runner” which allows you to see all available unit test.
Tests can also be run straight from context menu:
Performance & Memory Consumption
For some people this might be the most important part as not everyone can afford a high-tech workstation to run such monster. Should we see how CodeRush performs on a big stage?
I took a source of Enterprise Library 4.1 to run some test as I count it as a big enough solution having 1600+ files, 170.000+ lines of code across 42 projects. My first expectations are that both performance and memory consumption will rise in heights.
The first thing CodeRush will do when solution is opened, is complete parse of source code. A window like this should appear.
Once the source is parsed and cached in memory we can start working. I think there’ no need to spend much words about the testing itself, as I’ve just added a few classes, methods, properties,…
I have tested CodeRush on my home workstation. Here are specs:
|Processor:||Intel i7 920 @ 2.66 GHz|
|Memory:||Corsair Dominator 3 x 2GB DDR3 @ 1600 MHz|
On this machine CodeRush works like a charm. No delays, or anything worth a mention, but I’m pretty sure many of you don’t use such configuration to work at, or do you?
That’s why I made a test of CodeRush at my work machine as well.
|Processor:||Intel Core2Duo @ 2.66 GHz|
|Memory:||2 x 2GB DDR2 @ 800 MHz|
Difference between both machine is pretty obvious, but the results aren’t that much worse on this machine. You might notice some delays from time to time, but in general your work won’t suffer of bad performance.
How it should suffer when everything is kept in memory right? I’m not quite sure where actually is being kept, but if that’s in memory then something must be wrong.
CodeRush uses only 47MB to be aware of all 170k+ lines of code? At first I couldn’t believe it, but it’s true.
Of course this usage varies depending on what you’re doing in the code, but in my case it never crossed 80MB, what’s damn good.
More about memory consumption can be read on this blog post: http://community.devexpress.com/blogs/markmiller/archive/2009/06/17/performance-and-memory-milestones-in-coderush-and-refactor-pro-preview-of-9-2.aspx
Ease of Use
There’s not much to say about that. This depends on each user itself and a how natural he feels the way CodeRush works. For me it’s brilliant as it provides many ways to quickly learn it. We have at our disposal “CodeRush training window”, tons of visualization effects and at last Dev Guide – a great guide trough all of CodeRush features.
We’re getting close to the end and this is the last section. If you feel CodeRush doesn’t provide enough functionalities out of the box, you have ability to extend it by yourself as much as you want it. Of course there are quite a few CodeRush extensions out on the web.
I think this is also official site for CodeRush extensions: http://code.google.com/p/dxcorecommunityplugins/
There are many things I could talk about CodeRush, but I’ve pointed out the most important. This tool has some black spots, which needs better implementation (like “show reference” or “navigation from/to interfaces”) but overall this tool is just brilliant.
Next review will be about ReSharper 5.0 Beta, so keep reading.