Legacy Code: Wrap a method

I’m a big fan of Michael Feathers’s book Working Effectively With Legacy Code, and now and then I reread it because there’s always something to refresh or remind me.

Right now I’m looking at the “Wrap Method (67)” technique. It’s really simple. I’m just restating it here.
Continue reading “Legacy Code: Wrap a method”

Adventures in Unix administration

I’ve been underground and off the blog for quite a while now. A lot of distractions have been going on, and the biggest project over my last couple of years has been under heavy non-disclosure, so there hasn’t been much to write about and even less time to write it in.

But one of the biggest distractions is on its way out. That’s right… the criticalresults.com server is getting an upgrade! Yay!

Continue reading “Adventures in Unix administration”

The Single Most Effective Optimization

A year and a half ago, this really interesting scientific programming project more or less dropped into my lap.

The original code was written by a physicist–let’s call him Jim–who wasn’t a professional programmer but actually did an okay job writing and maintaining this Visual Basic Classic (pre-.NET) code for several years. “As a programmer,” someone might say in a gently mocking tone, “Jim’s quite a good physicist.”

So it’s cool. The important thing was to solve the scientific problem, and that it did. When I picked up the code with a mandate to get it working on a .NET platform and add a few features, though, I found it fairly hard to follow. A lot of the operations really needed to be event-driven but simply weren’t. There were a lot of modal dialogs and there were Windows forms with a ton of overlapping controls that got shown and hidden at various steps in the process.

So it was slow going, getting the thing to build and actually run on .NET. But the thing that saved my sanity in so doing was asking one simple question over and over again:

Does this code get used at all?

In many cases, the most difficult code was unmaintainable because nobody had to maintain it anyway. I consulted with the client, was told that the code implemented a feature that nobody used or even knew about, and simply deleted it. (After! Of course! Having all the originals under version control!)

There was a mishap or two in that regard, such as code invoked by menu options that seemed to be permanently disabled, but still. I could go back to version control (Subversion in this case), pull the original code back into Visual Studio, and massage it to get it to work.

But the massive reduction in workload caused by not having to work on 30% of the system at all more than made up for the few little problems. I’m pretty sure that the most effective development optimization of all, when working on legacy code, is simply cutting out the code that is never invoked or nobody cares about.

 

The Wire. Down to it.

When you’re up against a sudden deadline, focus on progress towards the objectives–not just bug fixes.

If you’re a big Critical Results fan–and who isn’t?–you may have missed my regular blog updates for the last week and a half. Let me tell you what’s going on.

Continue reading “The Wire. Down to it.”