Why learn Resharper

June 14, 2009 20:05

The ability to use tools is innate to humans, but not only to them.

Sea otters use stones to open recalcitrant mussels (and could keep a favorite stone tucked under the armpit, for the next use). Monkeys use sticks to dig holes. Herons use twigs as bait to catch fish and dogs use ticket stampers to validate tickets in trams.

Extensions of your hands.

But what is fundamentally different about the way we, people, use tools? Some naturalists consider it's our ability to enhance the tools we use, find new applications for them, adapt, and
learn. You, astute reader, already know that. Tools one have mastered are extensions of his hands, they help to perform mundane tasks and allow to concenrate on the important things.

Tools amplify your talent. The better you know them, the more productive you are.

That is the reason why you would want to learn Resharper (not just have it installed, using the meager Rename and GoToDefinition from all its exciting capabilities). Make it feel right in your hands, spend some time studying the ins and outs. And then, more and more often, you'll start finding yourself being focused on real problems: architecture, performance bottlenecks, scalability issues, all the high-level stuff  - instead of being swamped with routine coding tasks.

And to start an avalanche of learning experience, I just want to share one Resharper option with you. Just one. You might think you know it, but most likely you don't.

Code Completion.

Resharper provides 3 different types of code completion[1].


1. Symbol completion is the one we all use, mapped by default to Ctrl+Space. Simple and powerful, but if you switch off Resharper in Tools|Add-in Manager , you'll see the original dropdown from Visual Studio is pretty much the same.

Resharper version (notice it displays all overloads of a given method, and immediate members are emphasized with bold - e.g., Equals is not bold because it's inherited):



Visual Studio version (notice it mentions ConvertAll is generic - Resharper doesn't have that):



2. Smart completion (Ctrl+Alt+Space by default) filters the list of types, methods and varibles that match the expected type of an expression. In this mode, Resharper tries to guess the type or expression you need, and only those are displayed in the dropdown.
 


If you haven't used it - give it a try. It works in all places where Resharper can determine the expected type. (However, it might have been smarter - try Ctrl+Alt+Space when you're in a method that takes a string parameter, you'll see the whole list of String.Concat, String.Copy, etc - the ones you probably don't want to use anyway.)

3. Import symbol completion (Shift+Alt+Space by default) displays all types that match a given prefix regardless of the namespace. It's a fantastic feature to add types that are not imported yet. Symbol completion - the first one in this list - wouldn't work if a type is not imported.


Look above: the general Resharper suggestion pops up only after you have typed the whole name. With import symbol completion, it's much faster:



And, last but not least, you can use "camel humps" style of completion by specifying only first letters of the compound type name:


[Update] I was told I haven't mentioned extension methods here - indeed, import completion supports them as well. Have a look at the screenshot below: I had hit Shift+Alt+Space on foo and lo and behold, Revert appeared in the dropdown even though the corresponding namespace hasn't been imported yet. When I select the method, the namespace gets added automatically to "usings", the caret does not move, and thus I'm not distracted from further coding.   



Where to go from here.

The initial plan was to cover ten "overlooked" features. Later, the list was cut down to five, then down to three. And finally it's the only one here.

There's quite a lot to learn in any field, if you take it seriously. The nice thing about software tools - not just Resharper but virtually any tool - the knowledge you get pays off almost immediately.

So, go ahead - below you'd find the initial list of features I planned to cover. Learn 'em all and let me know if it helps or not :)

  1. Syntax highlighting
  2. Quick documentation
  3. Moving code elements
  4. Navigation
  5. Usage highlighting
  6. Stack trace Explorer
  7. Recent Files and Recent Edits
  8. Extract/Inline refactorings
  9. Live Templates



Footnotes.

  1. With regard to keyboard mappings mentioned in this post - you can always change them in Tools|Options|Environment|Keyboard , where typing resharper in "show commands containing" textbox would filter only resharper commands for you.

Comments are closed