My kingdom for a decent C++ refactoring tool

These days, I use Python much more than C++ for development, but I've still got a lot of C++ code to maintain. Over the years, the code has gotten crufty in places — mainly GUI and COM automation code, because it's hard to unit test, and thus hard to refactor.

Working Effectively with Legacy CodeThat is, until I read Working Effectively with Legacy Code by Michael Feathers. The book is truly amazing. Thanks to this book, I've now got a lot more of my code base into a test harness, and am starting to do some much-needed refactoring.

The problem is, automatic refactoring tools for C++ lag far behind languages like Java. Below, I'll list the C++ refactoring tools I've tried or considered, with some comments on each. Each of the programs listed below is an Addin for Visual Studio.

This one showed a lot of promise (note the past tense). Performance is a bit sluggish, and it's missing several refactorings, but the refactorings it does are generally correct. Unfortunately, development on the product seems to have halted (the website has been dead for a while), which is a shame. I'd definitely shell out for an upgrade or a new license if they could make some improvements.

Visual SlickEdit
I have to admit, I've never tried this one. I attempted to download the trial, but I felt there were too many hoops to jump through just for the "privilege" of deciding whether I wanted to give them my money…

Refactor! C++
In terms of pure functionality, this one is the best of any I've tried. The refactorings are powerful, and the interface is intuitive. The problem is, this thing is a real dog for performance. 2 gigs of RAM on my machine, and every time I scroll in the editor I get the hourglass. Their C++ tool is still relatively new, so I'm hoping this will get fixed.

Visual Assist
Visual Assist really takes a lot of the drudgery out of C++ development. The code coloring alone is worth the price, IMO. That's why I was really excited when they added refactoring support. And that's why I was so disappointed that it's worse than useless: the refactorings are underpowered, and what's worse, very often wrong; and unreliable automatic refactorings are worse than manual ones in my book any day. That said, a few of the simple refactorings are fairly reliable, like move implementation to source file and rename.

So, my search for a decent refactoring tool for C++ continues. Right now, I'm pinning my hopes on Refactor!, but maybe by some miracle the ref++ people will resurface with a shiny new upgrade. In the meantime, I'll have to stick with manual refactoring and plenty of unit testing.

5 comments to My kingdom for a decent C++ refactoring tool

  • Mark Miller

    Hey Ryan,

    Be sure to contact about that performance issue (we don’t put up an hourglass during scrolling or other background tasks, so that may be something else).

    We expect to release an update this week (Refactor! 2.5.4) with at least one significant fix to a reported performance issue in C++. And we have a team of devs who have a very good response time to any C++ issues reported.

    Support can also get you a daily build (first thing Monday morning) and you can verify that the performance issue is indeed fixed (and let us know if it isn’t) before we release.

  • Hi Mark, thanks a lot for responding to this post! It really shows a dedication to your users, and I really value that.

    I tried Refactor! with Visual Assist also installed. It could be those two don’t get along very well. So it wasn’t the purest test of the software, but a realistic one, since I’d plan on using them together.

    That’s great that a performance fix is already in the works. I’ll try Refactor! again when 2.5.4 is released.

  • After some research, I found that the problem with Refactor! being so slow isn’t directly its fault: It’s just that Intellisense in VS 2005 is really, really slow/buggy, and the added load of Refactor! just seems to throw it into fits.

    I tried turning off VS intellisense (relying just on the Visual Assist version), and performance improved significantly!

  • Robert Rapplean

    Hey, Ryan. Thanks for the primer. Any updates since last year? This will help with identifying the kinds of refactoring I can accomplish in short timeframes.

  • @Robert

    I believe that I eventually found that a bug with intellisense in VS 2005 was causing the slowdowns in Refactor! and Visual Assist. I also found that having one of these two installed would give acceptable performance, but with both the performance was terrible. This appears to have gotten a little better with SP1 for VS 2005, but not enough.

    I understand that intellisense is much improved in VS 2008, but I haven’t upgraded for other reasons. Ref++ doesn’t work in VS 2008 at all, but it’s completely abandoned now anyway.

Leave a Reply




You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>