Let’s continue the series on productivity…
My main motivation for using the tools and tips that I’ve shared on the series is so that I can have less interruption when I’m trying to write code and implement something. The idea being that when I’m writing code I want to have the least friction between me and my task possible. This line of thinking also applies to writing code.
VS 2005 Code Snippets
VS 2005 brought to the table a feature called VS 2005 Code Snippets. Code Snippets are just what the name implies: snippets of code that you can use. For instance, in order to create a class, instead of typing the full class definition, one could just type class and hit the spacebar, and the main skeleton of a new class gets created automatically. Or in order to create a property and the field that goes along with it, one could just type prop and hit the spacebar.
These are just a few examples: there’s a lot more that comes with VS 2005, and you can also search on the web for other code snippets that other developer have put out there.
I can’t really say a lot about Code Snippets because I don’t use them. Instead, I use a tool called CodeRush, which I’m going to talk about next. I’ve decided to stick with CodeRush for two main reasons: one is because CodeRush was available even going back to VS 2002, so I was using it way before Code Snippets showed up with VS 2005. The other reason is that, as far as I’m concerned, CodeRush is way better than Code Snippets.
If you have never seen CodeRush before, I suggest you check out the product’s Training Videos (try out the ones on Navigation, Cool Templates, and Refactoring). Those videos can show the product in a much better way that I can explain it hear.
If you’re already used to VS 2005 Code Snippets, all I can say is that, as far as I’ve seen, CodeRush is waaaaaaaay superior to that.
I’ve been using this product for about 3 years or so now. When I first started, like most people, I thought it was getting in my way. The main reason for that is because CodeRush tries to predict what your next action is, and it takes the action for you. For instance, if you type if and hit the spacebar, CodeRush will open and close parentheses for you. Until you get used to that, you end up having double parentheses: the one CodeRush puts in for you, and the one that you manually type in.
After I got used to that kind of thing, oh boy, it is really hard to work on a computer that doesn’t have CodeRush installed; one has to type a LOT more code. I sure prefer typing less code and focus more on the task I’m trying to accomplish.
I also like the fact that CodeRush helps me I’m constantly switching between C# and VB code. For instance, in order to create a method that returns a DataSet, all I need to type is mds (as in method dataset); this will cause a template to expand in the appropriate way, both in C# and in VB. That means that I don’t have to worry about the C# curly braces, or the VB verbosity.
I also like how easy it is to create your own templates (there’s a training video about this on their site). The last I’ve seen about VS Code Snippets, one has to deal with some nasty XML to create custom templates (maybe somebody created a visual IDE for it by this time, but there doesn’t seem to be anything in VS for that). To make the life of the developers who use our Milos framework easier, I’ve created a bunch of CodeRush Templates that expand to code that we use a lot but can’t really always remember exactly how to write it. You can checkout what kinds of templates we’ve create here.
Well, again, there’s a lot to be said about this tool. If you aren’t using anything like that, I suggest you give it a shot; download the trial version and watch the training videos so that you can see what you can do with it.
Since there’s a lot of features I like about it, I’ll just be posting a few of those that I really use all the time. Stay tuned.
ReSharper is another tool very popular out there. Unfortunately, I can’t say a lot about it, because I haven’t used it myself. I’ve seen people using it, and it seems like it’s another very good product.
I’ve heard of people using both CodeRush and ReSharper, combining the unique features of both tools to boost up even more the productivity. What I heard is that it takes a while to set that up, since we end up with Visual Studio, CodeRush, and ReSharper, fighting over shortcuts and stuff like that, but it can be done. Maybe I’ll try that at some point.
It doesn’t matter whether you’re using VS Code Snippets, CodeRush, ReSharper, or whatever other tool available out there; make sure you use something!!! Writing code in VS without using some tool like that feels like writing code in NotePad; and that’s nasty!!!
Bottom line is, when you’re writing code, stop for a moment and think whether you’re being as productive as you can when doing so.