Archive for October, 2008

Legacy Code

I remember the first time I heard the term “legacy code“. It was said with the implication that it was old, disliked, awful, God-help-you-if-you’re-sent-in-there-to-modify-it kind of stuff. That’s not really what it applies to, however. In many cases it’s really just code that’s not the most current stuff. It could be stuff that the previous guy wrote that you have to modify. And this is where I currently find myself.

I’m working on a project where the code was an internal application used by the folks who put together the parts that they make. It’s about three years old, written in Java, and contains almost no useful comments. The code is most definitely not self-documenting. It was put together by a summer intern with little actual coding experience and is a real mix of working, non-working, and perplexing code. Just upgrading to the latest java development kit has caused numerous warnings and exceptions.

I talked with the boss about what he wants done and then proceeded to take stock of what I’m dealing with. The UI isn’t terribly complicated other than a large table with lots of data and a few buttons mixed into the table. There’s some interesting functionality built into it (the table) and I’m trying to figure out if this is the best way to present this to the user or not. I’ve got a lot of leeway on how to proceed, but the requirement that it be done fairly quickly and cheaply.

After looking through the code in some detail, I have determined that the overall state of it is fairly “hacked”. It’s clear that the previous programmer didn’t understand why he was doing some things, especially related to event handling, putting icons into buttons, and computer graphics. So, in other words, there’s a lot of unnecessary code. The rest of the code is filled with uncommented, obscure variable names that are used, but of course, leave no indication of their job.

So, what’s a coder to do? I’ve tentatively decided to start by creating a new UI. I’ve discover Jaxx, which, although it doesn’t seem to be undergoing any changes and needs some updating for the latest jdk, does have some nice functionality and can help me get my project going quickly. This wasn’t an easy decision either, and I’m still second-guessing myself, but I figure that I can probably redo the basic UI with another similar toolkit in a few days, if necessary, for the next release.

With the new UI in place, I’ve been grabbing components of the code from the legacy application and moving it into the new framework I’ve built. So far, it has been a few days worth of work and I’ve got a much smaller, cleaner code base to work with. Already, the graphics are working better and there’s some separation of functionality into proper classes.

I plan to continue to grab code for the guts from the current app while cleaning it up, and adding some #!*!$%& comments and documentation. My decision might have been different if the circumstances were different. A clean, logical, well commented and documented code base would have led me to modify the current code as is. Notes on what wasn’t working yet would have helped. Since there was no source control used, I can’t even be sure that I have the latest code.

Am I making the right decisions? I believe so. I’ve made great progress in very little time and I’m reusing the existing code, so I’m not reinventing the part of the wheel that seems to be working.

What legacy do I plan to leave for myself and/or the next person who takes over the code?

  • I will comment the code and not assume that it’s so beautiful that it’s immediately intuitive. I’ll likely be the beneficiary of this a couple of months down the road.
  • I will use some source control, so I can know where the latest code is and do release control.
  • I will track working and non-working functionality.
  • I will spend time to think about the best way to accomplish the tasks at hand by doing diligent research and design.

I hope that this will lead to more interesting projects in the future with the successful delivery of this one. Doing good work leads to more work.

On Your Watch

I try to avoid politics with people I don’t know, but here goes; we’ll see how many people I insult with this post.

First, let me say how much I hate most politicians. With some exceptions, and despite most of them starting out with good intentions, they end up as self-interested, holier-than-thou, self-righteous, dishonest, and dishonorable windbags. Like most Americans, I have a vested interest in the current election. After eight years suffering through the results of the Bush Presidency (financial crises, foreign wars that we started, declining dollar, skyrocketing oil, etc.), I, like most of you, am looking forward to a regime change.

It’s an interesting mix of people running for the top spots. On one side, we have Barack Obama, who touts the word “change” as if that’s all it takes to make everything in Washington work as it should. He seems to have a good understanding of economic policy (if anyone can really “understand” it) and is clearly a very smart man. His running mate, Joe Biden, albeit a “gaffe machine”, has been around Washington long enough to know how it really works and can give Obama an earful on the foreign policy experience that Obama lacks.

On the other side we have John McCain, decorated war veteran, who served his country with distinction. He’s a smart man as well, and clearly cares for his country. He’s more “old school” on some issues, like maitaining troops in Iraq to ensure long-term stability. However, his plan to give more tax cuts to the wealthy (like Reagan’s and Bush Jr.’s trickle-down economics) and health-crisis plans (“we’ll assemble the best minds in the country”, gee, why didn’t anyone else think of that?) are clearly out of touch. His negative campaign has been thoroughly disgusting. If he wants to win any votes, he should run on his positive image and his policy plans. And, if he really cares about his country, he should end the divisive retoric in his messages. His running mate, Sarah Palin, while likeable, is clearly out of touch with the world. Who would have thought that she’d be tapped as a V.P. candidate? Clearly not Palin or she might have picked up a Time magazine, read it, and remembered what it was called.

Our current President dug himself into so many holes due to his own hubris, ignorance, and lack of respect for the opinions of others. While he didn’t bring down the World Trade Center, his administration had clues of attacks that were ignored. He didn’t make risky loans to homeowners, but he was in office making sure that his rich friends were well looked after, got all of the appropriate tax cuts, and had little oversight in the process. He clearly wasn’t responsible for invading two countries (Irag and Afghanistan), but, oh wait, that was all him, wasn’t it? Yes, it all happened on his watch.

How does all of this apply to you and me? It applies in several ways. First, it’s our responsibility to choose the next people to run the country. I can’t tell you who will do the better job. I can only implore you to select the people who are smart, won’t repeat the mistakes of the past, and will keep an open mind to changing the status quo. It also wouldn’t suck if they could pronounce nuclear properly (it’s new-klee-ur, not new-kya-ler).

Second, when you see things that are screwy in your own life (at work or home), you have the responsibility to make recommendations to the powers that can do something about them. If you’re the manager who has the power and you know something is going on in your own group, then it’s your responsibility to make it right. Turning a blind eye and hoping it will go away or somehow just work out, will not make it so. What happens is on your watch.

Will Code For Food

A couple of years ago I was looking for work in the Ithaca, NY area. Several people helped me find local companies and gave me moral support along the way. I ended up working for a small company that subcontracted me to a very large local defense contractor. It was a great experience on many levels. Since I left that job about a year ago, I’ve been working on some smaller personal projects, including my book.

Since I’m the most recent person amongst many former colleagues to go through the job search process, I’ve become the local go-to person for help with resumes and local companies. It’s a “job” that I happily do to help out my friends and neighbors. Recently a friend of a friend came here from India after a several year hiatus from coding to take care of a sick parent. His name is Joe Pierce, like most other folks from India that you speak to over the phone. I never met Joe or even spoke to him. I told my friend to have Joe send his resume to me so I could think of what local places he might look at and see if I could give him any good contacts.

When I received his resume and cover letter, it was a disaster. It covered three (!) pages and consisted of nine mostly short-term (e.g. 4 – 6 month) contract jobs over a twelve year period. Two things were painfully obvious looking at it. One, it was too long for such a short time period (a resume should be only one or two pages). Two, Joe was over 60 years old.

I’m not suggesting that being over 60 is inherently bad, but this is what he was presenting to a potential employer: I’m 63 years old, haven’t worked in 6 years, and most of my jobs have lasted around 4 months. Age discrimination may be illegal, but that’s no reason to stick it somebody’s face either. I suggested several changes:

  • Remove the years that he went to school – turns out this is becoming a common practice.
  • Highlight the skills he has in a good summary.
  • Shorten the whole thing to a page or two.

He was hesitant to take away the dates or change to a functional resume (people thought he was hiding something – he was, of course). On the other hand, your chances of anyone giving this guy a second thought are fairly slim. Your first job in job hunting is to get your foot in the door. You do this by having an intriguing resume and getting to the hiring manager, rather than the HR department. Once you get an interview, it will become very obvious that you’re old or young, short or tall, skinny or fat, American or not. None of these things should matter at all, but first you have to get to the interview. After that, you have the opportunity to present yourself in the best light possible and hopefully that comes out in person. You show up on time for the interview, you’re knowledgeable on the subject matter, and you seem like you’ll fit into the personality of the company.

Looking for a job is a full time job. Like any other job, you have to do some preparation, studying, and practicing to do it well. Get some good books out of the library (e.g. What Color Is Your Parachute), hit some good web sites (I recommend wandercoding.com ;-) ), and use your network of friends and former colleagues to help. Don’t dawdle – it’s your new job.

Epilogue: Unfortunately, unable to find work after 3 months, Joe returned to India.