Rewrite Dont Ever Do That Again

Netscape vi.0 is finally going into its first public beta. There never was a version five.0. The final major release, version 4.0, was released almost 3 years ago. Three years is an clumsily long fourth dimension in the Cyberspace world. During this time, Netscape sat by, helplessly, as their market share plummeted.

Information technology'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, yep. They did. They did it by making the single worst strategic error that any software company can make:

They decided to rewrite the lawmaking from scratch.

Netscape wasn't the first visitor to make this mistake. Borland made the same error when they bought Arago and tried to brand information technology into dBase for Windows, a doomed projection that took so long that Microsoft Access ate their tiffin, then they made it once again in rewriting Quattro Pro from scratch and astonishing people with how few features it had. Microsoft nearly made the same error, trying to rewrite Word for Windows from scratch in a doomed project called Pyramid which was shut down, thrown abroad, 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 information technology merely a financial disaster, not a strategic one.

We're programmers. Programmers are, in their hearts, architects, and the commencement matter they want to practice when they get to a site is to drive the identify apartment and build something 1000. We're non excited past incremental renovation: tinkering, improving, planting flower beds.

There's a subtle reason that programmers always want to throw abroad the lawmaking and start over. The reason is that they think the old code is a mess. And here is the interesting observation: they are probably incorrect. The reason that they think the quondam code is a mess is because of a key, key constabulary of programming:

It'south harder to read lawmaking than to write information technology.

This is why code reuse is and then hard. This is why everybody on your team has a different role they similar to employ for splitting strings into arrays of strings. They write their own office because it's easier and more fun than figuring out how the old role works.

As a corollary of this axiom, you tin ask nigh any programmer today about the code they are working on. "It'due south a big hairy mess," they will tell you. "I'd like cipher better than to throw information technology out and start over."

Why is information technology a mess?

"Well," they say, "wait at this role. Information technology is ii pages long! None of this stuff belongs in there! I don't know what half of these API calls are for."

Earlier Borland's new spreadsheet for Windows shipped, Philippe Kahn, the colorful founder of Borland, was quoted a lot in the press bragging near how Quattro Pro would be much better than Microsoft Excel, considering it was written from scratch. All new source code! Every bit if source code rusted.

The thought that new code is better than old is patently absurd. Erstwhile code has been used. It has been tested. Lots of bugs have been found, and they've been fixed. There's zilch wrong with it. It doesn't acquire bugs merely 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 non made out of all new material?

Dorsum to that two page part. Yes, I know, it's only a simple role to display a window, just it has grown little hairs and stuff on it and nobody knows why. Well, I'll tell you why: those are issues fixes. Ane of them fixes that bug that Nancy had when she tried to install the thing on a figurer that didn't have Cyberspace Explorer. Another ane fixes that bug that occurs in low retentiveness conditions. Some other 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 onetime versions of Windows 95.

Each of these bugs took weeks of real-world usage before they were constitute. The programmer might have spent a couple of days reproducing the bug in the lab and fixing it. If information technology'southward 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 y'all throw away lawmaking and get-go from scratch, you are throwing away all that knowledge. All those collected problems fixes. Years of programming work.

Yous are throwing abroad your market leadership. Yous are giving a gift of 2 or 3 years to your competitors, and believe me, that is a long time in software years.

You are putting yourself in an extremely unsafe position where y'all will be shipping an erstwhile version of the code for several years, completely unable to make any strategic changes or react to new features that the market demands, considering you don't have shippable code. You might likewise just close for concern for the duration.

Yous are wasting an outlandish corporeality of money writing code that already exists.

Is in that location an alternative? The consensus seems to exist that the sometime Netscape code base was actually bad. Well, it might have been bad, but, y'all 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 information technology.

Showtime, there are architectural problems. The lawmaking is non factored correctly. The networking code is popping up its own dialog boxes from the middle of nowhere; this should accept been handled in the UI lawmaking. These issues can exist solved, ane at a fourth dimension, by carefully moving code, refactoring, changing interfaces. They can be done by ane 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 lawmaking. 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 abrupt interfaces between the modules. But nosotros did it carefully, with our existing code base, and we didn't introduce new bugs or throw away working code.

A second reason programmers call back that their lawmaking is a mess is that it is inefficient. The rendering code in Netscape was rumored to be irksome. Simply this but affects a small part of the project, which you lot can optimize or even rewrite. You don't have to rewrite the whole matter. When optimizing for speed, 1% of the work gets y'all 99% of the blindside.

3rd, the lawmaking may be doggone ugly. 1 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, simply later switched to the more standard "m_". And so one-half the functions started with "_" and half with "m_", which looked ugly. Frankly, this is the kind of thing y'all solve in five minutes with a macro in Emacs, not by starting from scratch.

It's important to recollect that when yous start from scratch at that place is absolutely no reason to believe that you are going to do a better job than you did the first fourth dimension. First of all, you probably don't fifty-fifty have the same programming squad that worked on version one, so yous don't actually have "more experience". You're just going to make most of the old mistakes over again, and introduce some new problems that weren't in the original version.

The onetime mantra build one to throw abroad is unsafe when practical to large scale commercial applications. If you are writing code experimentally, you may want to rip up the function you wrote last week when y'all remember of a better algorithm. That'southward fine. Yous may desire to refactor a course to make it easier to utilise. That'due south fine, too. But throwing away the whole program is a unsafe folly, and if Netscape actually had some adult supervision with software industry experience, they might not have shot themselves in the foot and so badly.

sweenytyrize.blogspot.com

Source: https://www.joelonsoftware.com/2000/04/06/things-you-should-never-do-part-i/

0 Response to "Rewrite Dont Ever Do That Again"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel