Re-Factoring Isnt a Cure-All

 
 
By Peter Coffee  |  Posted 2002-04-15 Email Print this article Print
 
 
 
 
 
 
 

Over its lifetime, software often falls into a vicious circle: Enhancements make the code more difficult to understand, increasing the likelihood of errors—including errors in the changes meant to repair the previous generation of bugs. Continue unti

Over its lifetime, software often falls into a vicious circle: Enhancements make the code more difficult to understand, increasing the likelihood of errors—including errors in the changes meant to repair the previous generation of bugs. Continue until collapse.

Containing this software entropy is the mission of re-factoring, the practice of continually seeking out redundancy, identifying poorly located data or functionality, and transforming code in ways that do not change its function but increase its understandability.

"Re-factor mercilessly," commands consultant Ron Jeffries, editor of an extreme programming Web site (www.xprogramming.com). "When you find two methods that look the same, you re-factor the code to combine them. When you find two objects with common functionality, you re-factor to make there be just one."

Considered apart from other practices, re-factoring could sound like a cure that perpetuates the disease. It might seem that re-factoring tries to mitigate the risks of necessary change by looking for ways to make merely cosmetic changes. Like the diet without exercise, re-factoring alone will produce disappointing or even counterproductive results.

Re-factoring must be combined with other extreme programming practices that include continuous testing and integration (nothing that breaks the code ever gets beyond the daily build) and simple design (never deploying code that does more than is needed today).

Extreme programming doesnt try to forestall software change by anticipating future needs; rather, it treats changing needs as a certainty and tries to reduce software update costs by mandating reliable processes.

Developers will do well to perform their re-factoring with the aid of high-level tools, such as Rational Software Corp.s Rational XDE and TogetherSoft Corp.s ControlCenter, and supportive programming environments. Smalltalk programmers, for example, take for granted the ability to find all senders of any given method, easing the task of redirecting those messages to a new method that re-factors one or more others.

But re-factoring tools cant completely automate a simple mechanical process. There are similarities that are inherent and candidates for re-factoring, but there are other cases where consolidation might impede refinement of separate features.

Nor can re-factoring repair an organizational problem. If a company has a dozen Web sites, there are probably corresponding divisions among the business units. Those will have to be addressed before re-factoring can do its job.

Technology Editor Peter Coffee can be contacted at peter_coffee@ziffdavis.com.

 
 
 
 
Peter Coffee is Director of Platform Research at salesforce.com, where he serves as a liaison with the developer community to define the opportunity and clarify developers' technical requirements on the company's evolving Apex Platform. Peter previously spent 18 years with eWEEK (formerly PC Week), the national news magazine of enterprise technology practice, where he reviewed software development tools and methods and wrote regular columns on emerging technologies and professional community issues.Before he began writing full-time in 1989, Peter spent eleven years in technical and management positions at Exxon and The Aerospace Corporation, including management of the latter company's first desktop computing planning team and applied research in applications of artificial intelligence techniques. He holds an engineering degree from MIT and an MBA from Pepperdine University, he has held teaching appointments in computer science, business analytics and information systems management at Pepperdine, UCLA, and Chapman College.
 
 
 
 
 
 
 

Submit a Comment

Loading Comments...
 
Manage your Newsletters: Login   Register My Newsletters























 
 
 
 
 
 
 
 
 
 
 
Thanks for your registration, follow us on our social networks to keep up-to-date
Rocket Fuel