Screenshot of the Week: C++ Refactoring

My son has just finished up his first year of software development at college. In a demonstration of what I consider cruel and unusual punishment, his first programming language is C++ and his first development environment is Visual C++. I have to assume that the version of Visual C++ that the college unleashed on these unsuspecting students is some sort of reduced-functionality version, because it seems to lack certain functionality that I consider pretty basic, like refactoring.

I learned C years ago, and did some honest-to-goodness work using it, but never did take the time to learn C++, so I used this as an opportunity to close that gap. Naturally, I decided to learn C++ using the Eclipse C/C++ Development Tools (CDT).

The CDT provides some excellent refactoring support.

Renaming a C++ method

Renaming a C++ method

Keep the just-sorting-this-stuff-out nature of the work when considering the code in the screenshot.

This screenshot shows the first stage of the Rename refactoring. As expected, this changes the name of the method (function), the declaration in the header file, and any code that calls it. There are many other refactorings available, including ones that extract constants, fields, and functions. Note the Call Hierarchy view on the bottom view stack: use this view to find out how your function interacts with the world (calls and callers). There’s all sorts of cool stuff available.

The Eclipse CDT project has participated in every simultaneous release we’ve done and so it’s no surprise that they’re an important part of the Eclipse Mars Release. Help us test Eclipse Mars by downloading and testing a milestone build.

Epilogue: To my son’s instructors’ credit, they did avoid complex memory management issues, and did get the students to produce some pretty cool and very playable games featuring two-dimensional graphics. Those students that survive the programme are probably going to do well…

Caveat: I never really took the time necessary to properly research the functionalities provided by Visual C++ or spend any significant time using it. I have to assume that it’s very functional once you get comfortable with it.

This entry was posted in Eclipse 101, Mars, Screenshots and tagged , . Bookmark the permalink.

5 Responses to Screenshot of the Week: C++ Refactoring

  1. Martin says:

    Software engineering undergrad here. We got introduced to C++ (C++98 to be exact) as our first language in uni together with Visual Studio Express 2010. Why VS exp 2010? Because it was free. Why not Eclipse? A very good question is who uses Eclipse for C++ when you have VS. But to be honest, the refactoring feature wasn’t really thing I really missed there. As a C# guy, I’ve been using the refactoring function a lot and it is indeed quite weird that it is not in the C++ by default (it is not even in the current VS2013 ultimate). However, let’s put the languages aside and talk about the tools. I have been trying to use Eclipse for over half a year now and I just can’t seem to get friends with it. I have given it a number of chances. It is slow. It crashes and freezes. It looks old and makes me get that “Windows 2000 feel”. It burns my eyes out in the morning as it doesn’t have any dark theme. The “intelli-sense” (or auto completion, if you can even call it that) is just…, I wouldn’t even call it auto-completion.
    I’m pretty sure VS got some plugin for refactoring (in fact, here is one I just found:
    But you can go on and be like “but OHHH, why would I need a PLUGIN for that?!”. Well why isn’t there any good DARK THEMES for Eclipse? AT ALL????
    Protip for your little code knight: Check out VS community edition, they’re quite nice. Also got some pretty nice dark themes. (and auto-completion is superior compared to Eclipse)

    • waynebeaton says:

      There is a dark theme for Eclipse (released with Luna) that I hear is quite nice on Windows (I use Linux). Maybe I’ll make that next week’s screenshot. I’ve never really understood the obsession with skinning tools. But maybe that just makes me part of the problem.

      While tinkering with CDT, I played with some very large code bases and didn’t experience any crashes or freezes. The indexer did take a while, but it runs in the background so that’s no big deal.

      I found the auto-completion annoying in Visual Studio. But maybe that’s a function of just being used to it working in a particular way. I’m curious to know what specifically needs to be done better.

      I’m also wondering if maybe you’re using an older version. I know that the development team did a heck of a lot of work on the indexer in the last couple of years and a lot of related functionality improved dramatically as a result.

      FWIW, my “little” code knight is a 6’3″ 🙂

      • Martin says:

        Well, I’m using the latest version of Eclipse (Luna that is) and there is indeed a “dark theme” if you would like to call it that. I wouldn’t consider it as “quite nice” as it isn’t even complete. Many of the menu bars on it still appears white and many of the labels becomes unreadable, best part is how the code looks like a circus after enabling it.
        The auto-completion in Eclipse is just slow. And yes, I am using what is considered as a high-end computer and it takes seconds for the auto-completion to come up in Eclipse. Also, you could disable the auto-completion in VS if that was annoying you (Ctrl+space or something) but my point is that it is instant in VS compared to Eclipse where there is a good delay before it comes up.

      • waynebeaton says:

        There is a setting that specifies a delay when opening content assist. The default value is 500ms. My understanding of the history is that the delay was added because the constant popups get annoying. I believe that we’re changing the default setting to make it appear quicker with Mars (based on user feedback).

        There have been improvements in the dark theme with Mars.

  2. larsschuetze says:

    If you are commercially using VS for C++ you might end up buying Visual Assist ( Sometimes, I think because it’s existing they did not made the standard refactoring tool better. The plugin mentioned by Martin is still in beta.

    For the dark theming. Well, Eclipse seems to have taken some very bad decisions for it’s color handling (since they have no “global color set” every plugin inherits from unless it overrides it).

    I’ve studied at a technical university and just by writing all things down here I just realize how much we did in the beginning… We had C and ASM (algorithms and data structures) in the first semester and an internship in the summer pause where we’d to program Java (we flashed those Lego Mindstorm robots and installed a VM on them). Then they had to pass a course with obstacles. In the second semester there was C++ (computer graphics) and C/ASM (algorithms, tansforming C to ASM) and Java (software technology, design patterns).

    We used mainly VS back then and as a beginner I was just okay with the simplest behavior.
    Today I do not feel much comfortable with VS because of lacking refactoring capabilities. But, I have not bought Visual Assist and could have tested VS with it. It provides everything you mentioned about CDT.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s