unmatched (

[XKCD.com]

Things You Should Never Do [quoted]

The following is a directly quoted post from April 2000 by Joel Spolsky, the co-founder of Stack Overflow. I’ve quoted the post in it’s entirity as, while it is almost 11 years old, the concept discussed is still absolutely valid and is still overlooked and not understood by much of the development community. The original is here.

Things You Should Never Do, Part I

Netscape 6.0 is finally going into its first public beta. There never was a version 5.0. The last major release, version 4.0, was released almost three years ago. Three years is an awfully long time in the Internet world. During this time, Netscape sat by, helplessly, as their market share plummeted.

It’s a bit smarmy of me to criticize them for waiting so long between releases. They didn’t do it on purpose, now, did they?

Well, yes. They did. They did it by making the single worst strategic mistake that any software company can make:

They decided to rewrite the code from scratch.

Netscape wasn’t the first company to make this mistake. Borland made the same mistake when they bought Arago and tried to make it into dBase for Windows, a doomed project that took so long that Microsoft Access ate their lunch, then they made it again in rewriting Quattro Pro from scratch and astonishing people with how few features it had. Microsoft almost made the same mistake, trying to rewrite Word for Windows from scratch in a doomed project called Pyramid which was shut down, thrown away, and swept under the rug. Lucky for Microsoft, they had never stopped working on the old code base, so they had something to ship, making it merely a financial disaster, not a strategic one.

We’re programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We’re not excited by incremental renovation: tinkering, improving, planting flower beds.

There’s a subtle reason that programmers always want to throw away the code and start over. The reason is that they think the old code is a mess. And here is the interesting observation: they are probably wrong. The reason that they think the old code is a mess is because of a cardinal, fundamental law of programming:

It’s harder to read code than to write it.

This is why code reuse is so hard. This is why everybody on your team has a different function they like to use for splitting strings into arrays of strings. They write their own function because it’s easier and more fun than figuring out how the old function works.

As a corollary of this axiom, you can ask almost any programmer today about the code they are working on. “It’s a big hairy mess,” they will tell you. “I’d like nothing better than to throw it out and start over.”

Why is it a mess?

“Well,” they say, “look at this function. It is two pages long! None of this stuff belongs in there! I don’t know what half of these API calls are for.”

Before Borland’s new spreadsheet for Windows shipped, Philippe Kahn, the colorful founder of Borland, was quoted a lot in the press bragging about how Quattro Pro would be much better than Microsoft Excel, because it was written from scratch. All new source code! As if source code rusted.

The idea that new code is better than old is patently absurd. Old code has been used. It has been tested. Lots of bugs have been found, and they’ve been fixed. There’s nothing wrong with it. It doesn’t acquire bugs just by sitting around on your hard drive. Au contraire, baby! Is software supposed to be like an old Dodge Dart, that rusts just sitting in the garage? Is software like a teddy bear that’s kind of gross if it’s not made out of all new material?

Back to that two page function. Yes, I know, it’s just a simple function to display a window, but it has grown little hairs and stuff on it and nobody knows why. Well, I’ll tell you why: those are bug fixes. One of them fixes that bug that Nancy had when she tried to install the thing on a computer that didn’t have Internet Explorer. Another one fixes that bug that occurs in low memory conditions. Another one fixes that bug that occurred when the file is on a floppy disk and the user yanks out the disk in the middle. That LoadLibrary call is ugly but it makes the code work on old versions of Windows 95.

Each of these bugs took weeks of real-world usage before they were found. The programmer might have spent a couple of days reproducing the bug in the lab and fixing it. If it’s like a lot of bugs, the fix might be one line of code, or it might even be a couple of characters, but a lot of work and time went into those two characters.

When you throw away code and start from scratch, you are throwing away all that knowledge. All those collected bug fixes. Years of programming work.

You are throwing away your market leadership. You are giving a gift of two or three years to your competitors, and believe me, that is a long time in software years.

You are putting yourself in an extremely dangerous position where you will be shipping an old version of the code for several years, completely unable to make any strategic changes or react to new features that the market demands, because you don’t have shippable code. You might as well just close for business for the duration.

You are wasting an outlandish amount of money writing code that already exists.

Is there an alternative? The consensus seems to be that the old Netscape code base was really bad. Well, it might have been bad, but, you know what? It worked pretty darn well on an awful lot of real world computer systems.

When programmers say that their code is a holy mess (as they always do), there are three kinds of things that are wrong with it.

First, there are architectural problems. The code is not factored correctly. The networking code is popping up its own dialog boxes from the middle of nowhere; this should have been handled in the UI code. These problems can be solved, one at a time, by carefully moving code, refactoring, changing interfaces. They can be done by one programmer working carefully and checking in his changes all at once, so that nobody else is disrupted. Even fairly major architectural changes can be done without throwing away the code. On the Juno project we spent several months rearchitecting at one point: just moving things around, cleaning them up, creating base classes that made sense, and creating sharp interfaces between the modules. But we did it carefully, with our existing code base, and we didn’t introduce new bugs or throw away working code.

A second reason programmers think that their code is a mess is that it is inefficient. The rendering code in Netscape was rumored to be slow. But this only affects a small part of the project, which you can optimize or even rewrite. You don’t have to rewrite the whole thing. When optimizing for speed, 1% of the work gets you 99% of the bang.

Third, the code may be doggone ugly. One project I worked on actually had a data type called a FuckedString. Another project had started out using the convention of starting member variables with an underscore, but later switched to the more standard “m_”. So half the functions started with “_” and half with “m_”, which looked ugly. Frankly, this is the kind of thing you solve in five minutes with a macro in Emacs, not by starting from scratch.

It’s important to remember that when you start from scratch there is absolutely no reason to believe that you are going to do a better job than you did the first time. First of all, you probably don’t even have the same programming team that worked on version one, so you don’t actually have “more experience”. You’re just going to make most of the old mistakes again, and introduce some new problems that weren’t in the original version.

The old mantra build one to throw away is dangerous when applied to large scale commercial applications. If you are writing code experimentally, you may want to rip up the function you wrote last week when you think of a better algorithm. That’s fine. You may want to refactor a class to make it easier to use. That’s fine, too. But throwing away the whole program is a dangerous folly, and if Netscape actually had some adult supervision with software industry experience, they might not have shot themselves in the foot so badly.

[original source here]

Fantastic XKCD

We all know that every XKCD is fantastic, but this one just really tickled me:
self-referencing (XKCD)

There you have it.

today’s update

I checked in my first bug fix today! Slight sense of accomplishment when that happened. I’ve actually contributed something to the team. It wasn’t the most complicated of bug fixes, but it needed to be done and I got it sorted quickly and cleanly. Along the way I gained a lot of insight into the structure of the software and how it hangs. That said, I still know pretty much nothing about about the package (guys who have been here 11+ years still don’t know it themselves).

The main thing I think, was that I was able to show that I could understand the problem, then dive into some unknown code, find the “hub” and design and implement an efficient, effective solution without supervision. And, my coding practices seem to be in line with the other developers, which is definitely a good thing. After that I got to jump into a fix/update for our web client. This turned out to be extremely simple, and where I thought to go for “more aesthetic and dynamic” responses to user input I didn’t need to. So, by lunchtime I had committed my first two bits of code to the repository.

This afternoon I spent in the web client again, delving into greater depths. Most of what I was hitting up against was involving interactions between C# and JavaScript. I found a fantastic post explaining how to share dynamic variables between the two here, although I didn’t end up implementing as it was overkill for the requirements and we’ve established a more practical and elegant solution to that hurdle.

Off for my evening constitutional now, so more updating tomorrow.

New Year, new job, lots of new goings on…

I started my new role as Software Developer/Engineer on Monday. A very exciting start to the new year. A steady start to the pace with the first week or so set to be all about the induction process. I spent much of Monday and Tuesday meeting new people, going into meetings to get more information, and watching videos, reading PPTs, and reviewing LOTS of documentation. Today was more getting into looking at the actual product we make, and having an explore. Also starting automating some tests for it to get a bit of a handle on what it actually entails. So much to take in – not just the code (which I haven’t actually gotten into yet), but also the actually industry we are working for.

The company is Productivity Software, which supplies and supports a very large MIS for the printing industry. Most of my learning so far has been about printing, and the processes involved. All an integral part of understanding what we are trying to assist with and deliver for the clients.The office space I’m in great; it’s a big, open-plan, area with about 20 desks. Polished hard-wood floors, in an old warehouse-type building. Now it’s been refurbished and filled with advertising agencies etc. Very cool. I’m using a serious dev box, with a 64-bit OS running 8GB @ 2.67GHz on a 1TB HDD. The screen’s “only” a 30-inch widescreen LCD – hahaha!! Nice people to work with, very non-hierarchical and level, so anyone is happy to be asked questions and take the time to answer them. All-in-all a not unpleasant environment to be working as a developer finally.

Other than this excitement, I spent the last few weeks on Christmas holidays but stayed busy with planning and preparing for my upcoming wedding. It is absolutely amazing how fast the budget grows without even trying (and that’s just for the wedding itself!!), so if anyone wants to donate some cash this way it will be gratefully received [or stuff for the house too – I am more than happy to do a bit of product placement and “positive” reviewing here and anywhere else I can]. We’ve been quite well behaved and conservative with our planning and expenses for both the wedding and honeymoon (apparently we are running a wedding bill of between 1/2 and 2/3 of a normal wedding – depending on what a normal wedding costs…), and for kitting out the house, but it all still mounts up. Haven’t actually got a place yet, as there’s no point renting somewhere now, and anything we find now will be gone in a few months time (or if it isn’t, we don’t want it!).

Doing a bit of a surf on Etsy the last week or so also, and got very inspired to build some of our furniture myself; nothing too flash, but I’m going to be making some nice solid rustic bookshelves with concrete blocks and big slabs of kauri or other reclaimed wood, as well as some cute side tables for the lounge which will take a little of my wood-working skills to do (pics will be posted once made). One of these weekends I will be doing a bit of a cruise of industrial recycling yards to find some nice chunky units to refurb a little into side dressers and other furniture. I’m not just going for 2nd-hand, I’m going to be properly bringing them back to life – but they will definitely have character and a story to tell.

As part of starting the new year, starting a new job, and preparing for the next great adventure part of my life, I did a review of my eating and fitness habits (or lack thereof, ahem) and set myself some goals and some rules. For eating, I have got myself kitted out to take all the fixings for making healthy sandwiches at work for lunch (so much cheaper too!!) and I also have a supply of rice cakes for snacking, as well as finding some fantastic dried fruit bars that were also cheap (means I can have a week’s fruit supply without worrying about it staying fresh; and each bar is the equivalent of 2x minimum daily fruit intake requirement).

Also established myself a routine for walking at least every 2nd day, with plans to progress this to jogging/running pretty quickly [thanks to Rob’s blog post here -> @noozeeland]. Pulled out the weights bar, and setting up a dips block too. I’m definitely on a mission to get back to the old style lean Cameron – who knows, I may be actually able to be proudly flaunting abs on the beach soon.

I’ve got a few YouTube videos to post up as well, as I didn’t get any posting done while I was away – I really do need to get my iPad WordPress app configured ASAP – but I’ll do a separate post for them shortly.

2011 TSA calendar


Nothing else to say, really.

[thanks to fuckyeahdementia]

checking out the new tweet-embed plugin for WordPress

Just to try out this new tweet-embed plugin for WordPress, I’ll post the tweet of my this blog post just to be self-referential [this meant I edited the post after completion and it being automatically tweeted].

It pulls the tweet from Twitter with all the same styling as the Tweeter’s own Twitter page, but this also means it keeps the tweet live for each visitor to your blog (ie the time stamp displayed is relative to your page viewer’s time of visit to your blog).