Chi-Coder: The Curious Case of ReSharper.

I was recently introduced to ReSharper.  If you’re not familiar with the tool you can check out more about it in that link, but here’s a quick overview.  ReSharper is a C# tool (it works with other languages too) that acts as a programming productivity tool.  When it was introduced to me, it was sold as a “must have” programming tool.  The people evangelizing it all but worshiped at it’s digital altar.  The thing is, I don’t really feel the same way.

Productivity vs. Laziness.

One of ReSharper’s most obvious improvements is the way it helps you refactor your code.  As if the typical Visual Studio squiggles didn’t alert you of your coding errors enough already, ReSharper adds a bevy of new colors which alert you to all sorts of things that your code could be doing better.  Here’s a quick example of the type of thing ReSharper points out to you.

// How I'd make a data table before I used ReSharper.
DataTable dt = new DataTable();

// How ReSharper tells me to make a data table.
var dt = new DataTable();

On one hand, it’s pretty cool that ReSharper encourages you to use more modern programming paradigms like var.  On the other hand, if you’re new to coding and you have no idea why var might be more useful or better practice than DataTable just hitting the ‘Fix this for me’ button isn’t going to tell you why var is better.  In this respect ReSharper makes you both more productive and lazier.

Who’s standards are you coding by?

ReSharper wants you to use var pretty much everywhere possible.  I’m not 100% sure I like that.  Sure, you can make a pretty strong case that using var is good practice, but I have particular reason that I don’t like it.  They’re preferential, and maybe stupid, but they’re reasons I believe in.  For one, I like to strongly type everything I can.  I do this for readability primarily, but I also do it because I find it to simply be good practice.  Explicitly stating that my data table is, indeed, a DataTable makes sense to me.

I want to be fair here, so I’ll certainly concede that ReSharper, in almost every conceivable way, knows how to write better C# code than I do.  The product is built to improve your code, so the assumption is that the team who wrote it did so while picking through every C# coding practice with a fine tooth comb.  If ReSharper tells you to use var, more than likely, you should.  Also, it’s worth mentioning that you can change ReSharper’s rules, so you if you don’t like the whole var thing, you can turn it off.  That said, my counterargument to that is that now I have to learn this tool so far inside and out that I can find it’s rules database, locate the one (out of thousands) that I’m looking for, and disable it.  Why am I using a productivity tool if I have to spend hours upon hours learning it?

What happens when…

What I’m about to say makes me feel like a curmudgeonly old man or a crazy conspiracy theorist, but what happens if you rely on ReSharper and it doesn’t work anymore?  What happens if you’re forced to change languages, and the new language your using doesn’t have a ReSharper-like tool?  What happens if ReSharper “fixes” something in your code and you have no idea what it’s doing and thus no idea how to fix it?

I feel like all of these are legitimate and strong arguments against ReSharper and products like it.  I’m torn though, because the way I choose to use ReSharper makes it a great learning tool.  When I allow ReSharper to refactor code for me, I make sure that I know what it’s doing.  If I don’t, I go look it up.  When I first installed the product the var change popped all over my code and didn’t know what it was.  This prompted me to go look up var and see what about it made it useful.  I would most likely have never done that had it not been for ReSharper.  This has happened many times in my short career as a ReSharper user.

The thing that bothers me is that just because I chose to use ReSharper as a learning tool doesn’t mean other developers will.  Tools like this should require a programming test to use.  If you’re a coder right out of college with virtually no experience, you either a) need to do some coding without a crutch or b) prove that you’re not going to just let a tool like ReSharper do all the hard stuff for you.  If you elect to use ReSharper as a crutch to help you, without ever exploring why it’s telling you to do things then you’re short-changing yourself and you’re eventually going to be a worse programmer for it.

But there’s always a flip side.

Now that I’ve railed on ReSharper, I think it’s important to understand that these kinds of tools help speed up productivity in development environments where speed-to-market is critically important.  Games, for example, typically have release dates set months or even years before they’re finished.  As those days dwindle down, it becomes more and more important to make sure that every hour is being used as efficiently as possible.  There’s no doubt that ReSharper helps with that.  Not only that, but if ReSharper helps you write better code, and the code works, is it all that important that you understand every intricacy, especially in an industry like gaming, where a product typically comes out, has a few patches, and then dies.  Nobody is patching Uncharted, for instance.  If the tool helps write better code and that yields better products, then what’s the big issue?  Plus, there are tools like ReSharper for just about every major programming language out there.

In summation (he said in his best British accent)…

Look, I think ReSharper and tools like it have a place in programming, but I worry that some place far too high a value on what they offer.  Sure, ReSharper helps me, but in general, I know what I’m doing anyway.  I want to know how to code though, I don’t want some tool writing all my code for me; and I certainly don’t want to be reliant on anyone else’s knowledge base.

I realize that this post doesn’t relate to game programming very directly but I think it’s still a pretty important concept to comprehend.  As i mentioned above, the game industry comes with some of the most difficult deadline structures in all of programming, so I think that programming productivity tools become even more important in that environment than they are in others.  Because of that, it’s even more important to be stay vigilant and not be 100% reliant on any tool, no matter how good it is.