Working a little bit smarter

Created: Monday, October 15, 2007 7:03 AM Published: Monday, March 24, 2008 2:36 AM

I use JetBrains' Resharper to improve my coding productivity. One of the things I spend most of my time doing, is Test Driven Development, and one of the things I find myself writing most often is lines like this (using Rhino Mocks):

ISomething mockSomething = mocks.CreateMock<ISomething>();

I had a Live Template set up which lets me just type the "ISomething" and the "mockSomething" parts, but I've decided that even that isn't enough of a saving. Time to refactor the template!

In line with the teachings of Ruby on Rails (Convention over Configuration), and a little retrospection, I realised that I always make the mock name the same as the interface name, but with the "I" swapped for "mock", as in the example above.

So, one quick change later, my New Mock Live Template now looks like this:

I$MockType$ mock$MockType$ = mocks.CreateMock<I$MockType$>();

I've set the second $MockType$ to be the one which is edited so it's easier to see. Other than that, that's it!

Now all I need to type to get the example at the top of the post is:

nm<Tab>Something<Enter>

Easy

Feedback

Leave a comment
Your name:
Note: HTML not supported.
CAPTCHA Image Enter the code: