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 
 

Anatomy of Ugly: How Good Code Goes Bad

November 10, 2005 12:00 PM ET

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



Additional Resources

POLL RESULTS
Accelerate your knowledge of the IT world you inhabit by viewing the results of a series of polls taken by your IT peers. These polls of 100+ IT professionals each are available for full viewing. They cover key topics such as virtualization, processor performance, green IT, cloud computing and many others. Be a part of the buzz.
WHITE PAPER
Technology is complex. Keeping it running productively shouldn't be. To that end, you want to minimize the number of solutions needed in-house to simplify operations, maintenance, and support. Kodak offers a best-practices model. One company provides support for both scanner and software, for fast problem resolution without vendor finger-pointing. Download now!
WHITE PAPER
Utilizing demand intelligence improves the precision of pricing, product assortments, channel/store placement, and promotion, which are all essential for sustainable revenue management performance. Learn more, download this free whitepaper today.

White Papers & Webcasts

The High Performance Workplace
In this paper we examine the challenges and define the critical steps CFOs, CIOs, COOs and CEOs, in midsized global companies, can take...  

How to Reduce Eclipse BIRT Development Effort for Data Visualizations
Web applications can come with a long list of visualization requirements for structured data. By delivering your output through the BIRT Interactive Viewer,...

Extend, Replace, or Convert; which is the best way forward for COBOL Applications?
There are a number of choices when looking at ways to take existing COBOL applications forward. This white paper discusses the most common...  

Usability Is Everything
Learn what sets Workday's HR and Payroll solutions apart from the competition....

Accelerate SSL Encrypted Applications
The amount of SSL traffic is growing in the enterprise. Because it is encrypted, it cannot be properly controlled and accelerated. Blue Coat...  

The Value of Real SaaS at Workday
Cost savings, speed to value, and innovation brought to the enterprise by Workday's software-as-a-service solutions for HR and Payroll....

ESG Lab Field Audit
Many companies have successfully implemented Riverbed WAN optimization solutions within their Cisco networks. This ESG Lab Field Audit document explores the success that...  

SaaS at Flextronics, Inc.
Dave Smoley, CIO of Flextronics, discusses the real value of software-as-a-service and why he chose Workday for his HR solution....

Shape Your Apps Strategy to Reflect New SaaS Licensing and Pricing Trends
Why are smart companies choosing software-as-a-service? Find out in the complimentary Forrester Research report...  

Why Compliance Pays
This OnDemand webcast explores the relationship that firms with best compliance records have higher revenue, greater customer retention, lower financial losses from data...