All One Piece

Warning: The following is more disgusting than some Farscape scenes.

A parable:

Two drunks were outside a bar in the American Old West. One said to th'other, "I'll bet you a drink you can't take a sip from that there spittoon."

"Make that two drinks, and you're on."

"Okay."

The second drunk picked up the spittoon and began to drink, and he drank and drank until he emptied the container.

"Sheesh!" said the first. "What were ya thinkin'? All you had to do was take a little sip!"

The second, now turning a lovely pale-green, with much effort formed the words, "I tried. But it was all one piece."

The meaning of the parable: The contents of the spittoon is certain code; we've all seen instances of it. Sometimes, it's legacy code from before there were objects and unit tests. Other times, an unwisely written hack that was never intended for production and never refactored, and now it's too late. The second drunk is a foolish programmer who tries to tame this code, to work with it, maybe even to beautify it. But an intertwingled system is AllOnePiece. You can't take it in little bits. It's either all or nothing. And since the human mind can only effectively work with little bits at a time, this endeavor is bound to make him sick, sick, sick.


I recently encountered this phenomenon. A certain cross-platform legacy application had already been ported to a new platform, but the port was done on an old version of the application. All I had to do was to merge the already written port into the latest codebase. It took an inordinate amount of time, much of which was debugging, despite the fact that most of the job was already done.

Then I wrote a spike-solution of a rewrite for the application. It didn't support all the app's features, but it did include all the major parts and the connections between those parts. This end-to-end rewrite took only a little longer than the previous merge, with a lower proportion of time spent debugging, despite the fact that most of it was brand new code.

The reason for this was that logically separate parts of the legacy code had bled into each other. Even platform-specific code was only somewhat separate from platform-generic code, despite the fact that the app was cross-platform. Even to add a simple port to this cross-platform app required me to touch dozens of source files. And there was code in the legacy app to implement obsolete features, and some of this code was buggy, but even these bugs we could not simply get rid of, since we didn't know what other side effects might ensue.

--TimKing


See BigBallOfMud, PlayDohPrinciple, RewriteCodeFromScratch, MonolithicDesign.


EditText of this page (last edited July 5, 2005) or FindPage with title or text search