Computerworld
Quick Menu
Search



Ads by TechWords

See your link here


Subscribe to our e-mail newsletters
For more info on a specific newsletter, click the title. Details will be displayed in a new window.
Application/Web Development
Computerworld Daily News (First Look and Wrap-Up)
Computerworld Blogs Newsletter
The Weekly Top 10
More E-Mail Newsletters 
Computerworld 2007Subscribe to Computerworld
40 years of the most authoritative source of news and information for IT leaders.

Anatomy of Ugly: How Good Code Goes Bad

 

Sign up to receive Development Resource Alerts

November 10, 2005 (Computerworld) -- Like babies, most code is born beautiful, at least in the eye of its creator. But the only time I ever heard one programmer praise another's code was prerelease. In this newborn state, the code reflects the developer's original design, untouched by the unknown demands of future users.

But once code enters into use, this innocence is lost. Just as the wrinkles on a person's face are carved by his experiences, so do missed requirements, bug fixes and -- especially -- code being adopted by another programmer all result in additions and patches that become downright ugly. And no programmer wants to work with ugly code.

This leads to the inevitable desire to rewrite the code from scratch. The reasoning is seductive, and I have fallen for it many times: It would be easier to rewrite it than to try and fix it, because it's so messy that it's hard to understand. I've even justified it to myself on the grounds that it will increase the developer's accountability, since it's easy to blame problems on the legacy code.

There is some truth in this. If a developer doesn't understand the purpose of code written by others, he is more likely to leave it and write around it than to remove it, so the code becomes bulky and confusing. Rewriting it can serve to streamline the code, making it easier to follow and understand.

But there is also a hidden trap, as I have confirmed over and over: The problem is that the developer who wants to rewrite it doesn't understand it, which is why it needs to be rewritten.

Think about that. How can you recreate something you don't understand?

You can't, of course. So, what happens is that all of the battle scars of the code -- that is, the code added to handle unforeseen issues such as undocumented idiosyncrasies in the operating environment -- are lost, and with them the hard-won experience that required the code to begin with. The new code must literally grow up all over again, until it, too, becomes ugly.

Let me give you an example. We have a product that interacts with a browser, the Document Object Model (DOM) and the operating system. Once our first version went into production, we began to uncover an endless procession of subtleties, undocumented behaviors and outright bugs in each of these interactions. In one case, we discovered that passing a URL that was in a different domain than the one that initiated it had to be invoked in a completely different way due to security patches. This was only one small example of perhaps hundreds of

Continued...
1 | 2 | NEXT  



Print this Story Send Us Feedback E-mail this Story Digg! Digg this Story Slashdot this Story
"A few weeks ago, a video demo for Firefox Mobile showed up on the Internet with very little fanfare (it..." Read more...
"Microsoft will never come right out and say it, but its actions speak louder than words: Vista is dead...." Read more...
Read more Development posts or See all Blogs
Report: AMD to spin-off manufacturing
Microsoft scales out SQL Server 2008, wants to 'democratize BI'
Oracle tries to step up on high-end databases
More top stories...
IBM launches Bluehouse, a Facebook for business
iPhone grabs top smart phone spot
Wi-Fi helps college students get better grades, survey says
Too much junk food, too little exercise and a 24/7 tether to technology? Your body ain't happy, friend. Let us count the pains.
Instruments on the surface of Mars have detected falling snow that is likely evaporating before it reaches the planet.
One positive development stemming from the collapse of Wall Street may be a boost in interest in computer science and IT careers among students who were previously interested in financial services jobs.
Getting new software installed on Linux doesn't have to be hard, but it can differ depending on what you're installing.
Reviews, analyses, how-tos, visual tours, hot issues and predictions about Microsoft's new OS.
Four years from now, the IT field will be a vastly different place. Will you be ready?
All Zones
Application Performance Zone
Business Continuity Zone
The File Data Management Zone
Security Management Zone
The SAS Zone
Business Intelligence and Analytics Zone
Windows Protection Zone
The Enterprise Search Zone
Software as a Service Zone

Ads by TechWords

See your link here
Sold on SOA

(Source: Computerworld) It's the hot technology for most large companies, but business, technical and cultural issues must be addressed for a successful SOA implementation. Get the whole story, from the big picture to the how-to-do-it details, in this Executive Bulletin. Download this Executive Bulletin (a $49.95 value) for Free, compliments of Fujitsu.
Download this executive briefing download
Driving Business Success Through Workgroup Choice and Flexibility
Download this white paper compliments of Novell!
(Source: Novell) The structure of your workgroup environment plays a vital role in enabling your knowledge workers to be productive and collaborate securely. And IT choice and flexibility can mean the difference between reactive spending and proactive investment. Boost your competitive advantage with a workgroup infrastructure that lets you deliver the tools and services that are right for you. Download this white paper to learn how Novell offers a variety of solutions that give you the flexibility to address critical business initiatives and workforce productivity.
Download this white paper go
From Laggard to Leader: Transforming the Data Center
From Laggard to Leader: Transforming the Data Center
Register for this complimentary webcast today!
Go to the webcast 
White Papers
Read up on the latest ideas and technologies from companies that sell hardware, software and services.
Project Portfolio Management - Boost the value of IT
Core Network Services Survey: The Costs and Impacts of DNS and IP Address Management
Six Project Metrics Every CIO Should Know for Application Delivery Success
View more whitepapers