Saturday, September 16, 2006

Do you ever need to do a complete rewrite?

Joel Spolsky's article about rewriting software has always struck me as a very well reasoned argument for never rewriting software from scratch. He mainly talks about Netscape's attempt to rewrite their browser from scratch. You might claim this was a reasonable success in some respects since it led to FireFox, which now has a pretty decent share of the browser market (about 10% I guess). But compared to the market share Navigator had before they started their rewrite it is still pretty miniscule. Of course they may well have lost a lot of that market share anyway, since MS was installing their browser on every new machine that was sold. But MS stopped developing Internet Explorer after they achieved almost complete ownership of the browser market, which gave FireFox a chance to gain ground. So basically we'll never know what would have happened if Netscape had continued with their old codebase.  

So I was somewhat disturbed to find out one of my previous employers had decided to rewrite one part of the software product they sell. I could say who it is but I don't really want to have them getting their legal dogs onto me. I worked on this part of the system for over six years and it is pretty large (with third party code it's over 500,000 lines of code) and pretty central to the whole product. It is written in Delphi and the rewrite will be in C#. As a developer, you always want to work on the latest cool technology and always think the legacy code you're working on is a complete mess, so I'm sure they are happy to be involved on a green field project like this but I'd hope the people in charge would have a very good reason for wanting a complete rewrite, but frankly I can only think of one. It's probably getting increasingly difficult to get hold of good Delphi developers. The market is shrinking and from what I can see the good Delphi developers are moving onto other things, like C#.

I've heard they have a team of five people working on this and it is planned to be done in a year. OK, here's my guess on how long it will take. Whilst I worked there, there were probably on average about 2 developers working on this bit of the system. I'm guessing it continued with the same level of manpower after I left. When I started they already had a working product, if a little rough round the edges, so say that took 2 man years. I started in '98, 8 years ago, so we have another 16 man years of work, 18 in total. Divide that by 5 people and we have about 3.5 years to write a piece of software that has the same functionality as what they currently have... Lets hope they have five really good developers...

As an aside, it has to be pointed out you'd need to have very good reasons to want to get to C# anyway, whether through a rewrite or a migration. Whatever people say, Delphi is still a fine choice for Win32 desktop applications. OK, it is missing some of the nicer features of .NET like reflection and the availability of 3rd party controls is drying up but it still produces small, quick native apps. And if you have a stack of Delphi code, throwing it away is a very expensive thing to do.

But is there any other way? I thought about this when I worked at the company. Like any developer I wanted to move onto new technology so I had a long hard think about how to get from the Delphi codebase we had to C#. One choice was Delphi for .NET, but this looked like a pretty painful route, especially with the number of 3rd party controls (many no longer supported) we were using. My though in the end was the best route to take would be to componentise what we had using COM. OK, this wouldn't really be a step forward, more a step sideways, but once you've got those components in place you could start to replace each bit piece by piece.

But I hear you saying, that would take even longer, since you still need to rewrite each bit and you have the overhead of separating them into COM components in the first place. And you'd have to use that horrible COM Interop stuff as well. All true, but the major advantage of this approach is that you will always have an application in a state that is ready to ship, or very close at least. A complete rewrite means there will be a very long period of time when you can't ship anything at all, unless you want to add new features to the old codebase at the same time as adding them to the new codebase, which will be even more expensive and painful.

So I wish them good luck with their development. I really do hope it works out, because my livelihood now depends on their software...

No comments: