Tuesday, October 26, 2010

Automation of refactoring

I'm really missing automation in my refactoring. A lot of what I do on a day to day basis, is robotic code moving that has no impact on functionality (or it should not if you don't make human mistakes). A nice tool for doing basic operations, such as moving functions from one class to another, changing a parameter list, extracting a function from a code chunk, etc. would do so much good!

Many refactoring operations aren't difficult, but even for a refactoraholic like me they can be
  • Robotic
  • Repetitive
  • A pain in the ass
    • The number of primitive actions can be quite large (up to 10-12)
  • Bug-prone, 
    • It's easy to make a mistake in the long list of primitive actions, and then your code has unnecessary bugs, which were introduced out of good intention
I use Visual Studio 2008, and luckily I can see that Visual Studio 2010 has a lot of the things I've been looking for.  A lot of the refactoring operations have in fact been automated, and I'll probably write about that in my future posts.

2 comments:

  1. I found Visual Assist X's "Extract Method" function really useful when I have to move code around.

    ReplyDelete
  2. Yes, I've seen it too. Unfortunately it only works in the very simple cases. I think what's needed is some sort of interactive dialog along the lines of "are you really sure you want to create a function with 15 parameters? Please select the parameters you will actually use".

    ReplyDelete