Monday, February 23, 2009

Starting From Scratch? Never Say Never

While following my blog quest, I ran across an interesting article which told several compelling reasons why the PHP group is not just re-writing the PHP code from scratch for the upcoming PHP 6.

As I was sifting (or slogging, perhaps) through the comments, I found a link to an interesting article entitled, Things You Should Never Do, Part I by Joel. My curiosity sufficiently piqued, I started reading.

At the risk of over-simplfying, the author basically says, "Never rewrite your code from scratch." It's a bold statement. I can certainly appreciate the intention behind it. From my own experience, I know that rewriting code from scratch can be a long and daunting process.

Most programmers I know (with myself as a definite inclusion), tend to look back at their "old" code and think, "I could do that better if I rewrote it today." Sometimes the code really isn't very old at all.. only a few months. For the most part, I think that having that feeling is a good thing. It means that you've been learning. It means that you have the drive to improve yourself and your work. But acting on that feeling often leads to trouble, just as Joel says. I like how he points out that new code isn't necessarily better than old code -- old code does not rust.

I also concur with his assessment that so-called "old" code is better tested. It is more mature. And I see where I sometimes need to repent of saying that the legacy code is a mess. Joel hits the nail on the head when he identifies that old code looks messy because it is easier to write code than to read it.

So I agree with the spirit of the article. But I take umbrage with a particular word: never.

You (or a software company) should never rewrite their code from scratch? That I don't believe. Now I realize that Joel's article was written back in 2000. I haven't followed his blog to find out if there was a Part II, or if he recanted what he said. But I believe there are some instances where it can be a very good thing to rewrite your software from scratch.

After pondering for a while, I came up with the following list of times when rewriting your code may be beneficial:
  • When you are building something new. Not just a new version, mind you. A new product or perhaps a paradigm shift on an old product.
  • When you are adding new features which the old code cannot support without difficulty. Sometimes you can be painted into a corner by legacy code.
  • When you want to take advantage of new technologies or languages.


I find that Mac OS X is a great example of how rewriting code can be a good thing. Rather than take OS 9 (which was a mature piece of software with a solid background) and turn out a new-and-improved version, they scrapped it instead. They rewrote things from the ground up. They ended up with a terrific operating system... my favorite, in fact.

[I'm adding this aside to recognize that OS X was built on some "old" code, specifically UNIX and NeXT. Although it was not written completely from scratch, I think it still exemplifies the point I am trying to make.]

Now there was a painful transition from OS 9 to OS X. For a while the best programs were not available for OS X. Users clung on to the last vestiges of OS 9. But over time, new software emerged. I think many Mac owners are now glad that they don't have to worry about "Classic" mode anymore.

Personally, I think that this is something that Windows could benefit from. They've taken many pages from Steve Jobs' book, why not this one too? A lot of the issues (especially security issues) in Windows linger because of backward compatibility. But a new OS would mean that old programs wouldn't work anymore. Microsoft, Windows programmers, and users would all have to take a leap of faith. But it can be done.


Another example is with some software my previous company was developing. We had some legacy AS2 / C code which was really just a nightmare to maintain, let alone improve. We looked at the situation and decided that we should take advantage of the new AS3 and rewrite. The new product turned out much better than the old one, both for the user and programmer. That's not to say it was perfect, but a definite improvement.


There are probably some other times when a total code rewrite would be beneficial. So certainly we shouldn't say never. But that decision needs to be made cautiously, with eyes open to the risks. If possible, keep up development on the previous version of the software.

I suppose that the moral of the story is that there is a time and season for all things -- even rewriting code from scratch.

Thursday, February 5, 2009

Read, Think, Write, Learn

In trying to be a conscientious, career-minded programmer, one of my goals has been to keep abreast of the goings-on in the programming world. Keeping current and learning new things is really vital for the overall success of a programmer. It keeps you relevant, it keeps you from being pigeon-holed, and it helps you stay interested in developing software, to name a few reasons.

In pursuit of that goal, in the last few months I've been looking for interesting blogs and sites that are relevant to my work. There are a few that I felt are worth mentioning. In fact, you'll notice that I've even gone as far as to add links on my sidebar! (Go ahead, look over there.)

The first one I want to mention is the excellent Grant Skinner's gBlog. I was first introduced to this blog sometime a year or so ago when I was doing a lot of Flash work. At the time we were having some problems with our application which turned out to be memory / garbage collection issues. Enter the gBlog. Mr. Skinner has some very helpful information out there about memory management in ActionScript 3 (AS3). Now I may have run across his site before, but this time it stuck. Useful information and really cool demos? That's a site to not forget.

More recently (in the last month or so), I've started following another blog called Coding Horror written by Jeff Atwood. I have found this blog to be very interesting. He has great writing style that practically compels me to read it and he covers some, dare I say, delectable topics. Plus he is working on a very cool site: Stack Overflow.

The thing that I love about these two blogs is that while I might not agree with everything they write, they cause me to think about stuff I care about. And that, my friends, is worth its weight in kilobytes.

Monday, February 2, 2009

Weekend Warrior

This weekend I was very industrious. My usual routine involves me helping my wife clean the house and then avoiding any other thing which resembles work. But this Saturday was different.

I fixed our leaking toilet by replacing the flapper. Although the toilet mechanism isn't terribly complex, I was still worried that I hadn't properly diagnosed the problem. But ever since installing the new flapper we haven't heard any more of the tell-tale running water.

I installed a programmable, digital thermostat. This was a bit more like rocket-science... or perhaps defusing a bomb? But the instructions were very clear and I didn't even electrocute myself. Within a few minutes time I had removed the hold and installed the new. Now we can actually tell what temperature it is set at instead of the old-fashoned guesswork. And it was easy to set up for our schedule. I'm hoping to see some savings in the utility bills this year.

I built some shelf additions for our DVDs. We have a deep bookcase which is deep enough for two rows of DVDs. Each shelf is also pretty tall, so I got the idea to raise the back layer of DVDs so we could see the back row. So while I was out buying the flapper and thermostat, I picked up some wood and got it cut right there at the store. I probably should have planned it a bit better and measured the wood I purchased, because when I got home I was miffed to discover that the wood was not the size it had claimed to be! I don't know if it was mislabeled or what. But I salvaged the operation and now we have our DVDs shelved in all their glory.

It felt good to get so much done around the house! Not that I necessarily want to abandon my typical ways, but now and then I enjoy a little weekend handiwork.

Monday, January 19, 2009

New Year, New Job

Seeing that 2008 was a hard act to follow, the new year has come on stage with trumpeting fanfare and has presented me with a new job.

As I was not fully satisfied with my current job, I felt that I shouldn't snub any opportunities that came my way. This particular opportunity was audacious enough to call me up directly! Actually, I've gotten a couple of calls from people who have found my profile on LinkedIn. My new job came from one of these calls.

I interviewed in mid-December, but didn't hear back for almost a month. But eventually the job offer came. When I told my boss I'd be leaving my current job they gave me a counter-offer, but after considering my options the new job was just too appealing. Although it is somewhat intimidating, I feel like I've made the right decision for my career and family.

Although I am excited to get into a new job which will take programming more seriously, it will be kind of sad to leave my current job. I've made some good friends. I've enjoyed some fun projects. I've tried to make a difference. It was nice to know how valuable my manager believes I am. The fear of change has tried to deter me from changing jobs, but I have resisted.

In just one week I'll be starting my new job. It is kind of stressful and nerve-wracking, but also exciting.

. . .

Quit my job down at the carwash
Didn't have to write no one a goodbye note
That said, "The check's in the mail, and
I'll see you in church, and don't you ever change"...

Sunday, January 4, 2009

Reflections

The dawning of the new year has caused me to pause and reflect on all that has happened to me in 2008. There have been many changes, including some important life-changing ones which I had been pining for over the years. It was a wonderful year.

The biggest and best change of the year (not to mention my life) was getting engaged and married. It is strange how it seems so long ago, even though many weeks tend to fly by. My beautiful wife has made me so very happy. It is hard to imagine life without her now.

The other big change for me was getting laid off and finding a new job. Career-wise, this year has been a veritable roller-coaster! But I think I have been improving my skills along the way. Along with things I've been learning at work (like iPhone app programming!), I've also been working on my own projects and learning from there. Work has also brought about little things, like when I really got into using wikis.

Another change I've experienced is regularly going to the gym. Off and on over the years I've tried to be good about exercising, but in 2008 it actually happened over the whole year. That's another thing that I have my sweetheart to thank about.

Last year brought many good times in the way of games. At the beginning of 2008 I was still riding the wave of Gamevember 2007, playing Mass Effect and Assassin's Creed. Rock Band has been a lovely year-long experience. It is one game that my wife enjoys, and we've built up a decent collection of songs now. Then Rock Band 2 made it all the better. I've also enjoyed Spore, Castle Crashers, and others! There have also been some great non-video games such as Mexican Train and Quiddler.

It has also been a great year for music and movies. Between my wife, Rock Band, and Pandora, I've expanded my music selection quite a bit. For movies, I very much enjoyed Iron Man, The Dark Knight, Kung Fu Panda, and Wall-E (which I finally saw over Christmas). I also experienced some great older movies, like when my good friend gave me Yojimbo and Sanjuro.

Playing D&D with my friends has been just plain awesome. The game is very fun to play, and I've enjoyed being the DM. But it has also been really fun to be able to regularly get together with my friends.

Recently I've started reading again. I hope that this is something that I can carry over into 2009. There are always so many things that I want to do (including writing on this very blog), but I should try to make sufficient time for reading.

The 2008 holiday season was a joyful time spent with family. I love and appreciate my family so very much. I have especially enjoyed watching and playing with my nephew during his first year. It is fun to be an uncle.

Now looking forward, I'm excited for the things which the year 2009 will bring.

Saturday, December 6, 2008

Coding for the Weekend

Sometimes I feel like I'm not living up to my potential as a programmer. All too often I find myself wishing that I were in a situation where I would be expected to write better code. I feel like there is still so much for me to learn, but I've somehow missed the boat.

I've got a pretty good job. I'm glad to have it and I've got some terrific co-workers. The trouble comes in two flavors. Our company has deep seated custom of doing what is needed at the moment without planning ahead. Being flexible is one thing, but we spend days and days resolving problems which could have been fixed by planning and writing the right code in the first place.

The other trouble I find is a bloated Frankenstein's monster which we dubiously call our legacy code. It is patched together into a terrible tapestry. Some pieces are wonderful gems of ideas and well-written code. But for every pleasing morsel there are seemingly dozens of fetid carcasses. And they are all tied together. Nothing is separated, all is unclean. I cringe at some of the security issues that are just glossed over.

I realize that this scenario isn't exactly uncommon. But the combination of the two problems (at least from my perspective) leaves me in a place I do not want to be. I find myself doing a lot of mediocre work just to get the job done. I never feel like I'm taking ownership of my code, as the kids say. But I can't justify taking the time to fix many of these problems. Those kind of decisions are not part of my job description.

But there are a few rays of light that peek through the dark clouds from time to time. We have a relatively new manager who seems to value most of the software practices that I do. I'm hoping that eventually he will be able to change things. And I always look for little places where I can write better code.

I'm trying to keep abreast of many best practices and new ideas, but it can be difficult. One issue that I worry about is that I have little to no work experience with things such as:

  • Unit testing (let alone having a testing group / phase!)
  • Development life-cycles (Agile, XP, Waterfall, etc.)
  • Design and documentation
  • Code reviews

So I'm trying to learn on my own and incorporate things into my work as best as I can. But my recurring lament is the lack of time for working on my own projects. I'd like to participate in some open source projects and work on my own projects. But they always get pushed to the back-burner.

So I guess for now I'll just keep plugging along like good ol' Charlie Brown. I'll try to do the best I can, but I know that there will still be many days where I'm still coding for the weekend.

Saturday, November 29, 2008

Thankful

As I've enjoyed this Thanksgiving holiday weekend, I have had time to reflect on many things for which I am grateful.

The first and most important thing I am thankful for is my beautiful wife. She is amazing. There is never a day that goes by where she doesn't do something for me. Some days it is wonderfully new. Other times it is just the multitude of little things. But every day she lets me know that she loves me. And I love her too.

I am grateful for my family. On my side of our family, I have people whom I have loved all my life. I have an adorable little nephew. On my wife's side, I have people who have taken me into their homes and lives.

I'm grateful for our home, our cars, and our jobs. Although sometimes expenses or frustration can cloud my view, when I stop and survey what I have, I am content.

There are so many things I am grateful for. Some are small things like playing Rock Band or watching a movie. Tasting delicious food. Or just sleeping in under a warm blanket.

Sometimes the holiday season can feel cliché, but I am genuinely thankful for the reminders the season provides for me.