CIO
Code Of Practice
Sue Bushell  10 May, 2004 10:11:58

Developers have been refactoring for years and will continue to do so, and in this regard, it is nothing new. But with the advent of new "agile" processes like extreme programming (XP) refactoring really rules.

Not so long ago, Robert Watkins, a senior Java architect for Suncorp-Metway, was working on a large and complex system development requiring loads of integration when it became clear that some underlying assumptions were proving to have been just plain wrong.

A reasonably common experience whenever there are unknowns prior to development, the discovery was nevertheless a real inconvenience: It meant the company would have to make significant change to a large part of the underlying application if its performance was ever to prove satisfactory. In many organizations that would have meant either undertaking "major surgery" or living with the problem because the cost of fixing it was seen as prohibitive.

At Suncorp-Metway they know just how to make those improvements without taking the system offline and without dropping all other programming work.

"What we did over a period of time was to introduce several 'refactorings' to isolate the performance problem and let us put in a functionally similar piece of code that happened to run a lot better," Watkins says. "It took about two months to do, because we had to keep the system working and we couldn't drop everything we were doing, but at the end the system was actually functional because the speed was acceptable. If we hadn't solved this we wouldn't have got the system into production."

Watkins, an application systems specialist in Suncorp-Metway's J2EE Centre of Excellence charged with promoting industry best practices in development, says whether or not his organization actually refactors varies from project to project. Officially the group has been behind refactoring for about nine months.

"Refactoring is all about changing code without changing behaviour," says agile programming expert Dr Neil Roodyn. "You don't expect to get extra features from doing it; you do it to keep the code maintainable. Refactoring is like keeping the workshop tidy; it enables you to work in a clean and tidy environment."

But refactoring can also be a low risk, incremental development methodology that can save businesses money by helping them build on existing infrastructure and experience.

ThoughtWorks chief scientist and software development guru Martin Fowler describes refactoring as a disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behaviour. At its heart, he says, is a series of small behaviour-preserving transformations (refactorings), each of which does little on its own but which put together in a sequence, can produce a significant restructuring. "Since each refactoring is small, it's less likely to go wrong," Fowler says. "The system is also kept fully working after each small refactoring, reducing the chances that a system can get seriously broken during the restructuring."

Most organizations struggle with "worn code": Code that has been modified, extended or truncated to suit changing business requirements, until the integrity of the original design is lost and any documentation rendered useless. Refactoring the code can be a useful and relatively painless way to address the problem. In fact some development technologies, such as extreme programming, depend on it (see "Sabre Takes Extreme Measures", page 118). And refactoring comes with significant business benefits. Organizations that refactor existing software can better leverage IT investments and reduce the risk inherent in further additions to software in the future.

"While the structure and code has been modified, the user should not see any difference in the system," says Colin Garlick, senior trainer at Wellington, New Zealand-based Software Education. "As such, any tests, whether automated or manual, should be able to verify that the functionality of the system has not been changed." He points out that software developers have been doing refactoring for years wherever an existing system needs to be modified in response to new or changing requirements but the structure of the existing system does not facilitate the required modifications.

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

Enter the fully qualified URL, eg. http://www.example.com/
Users posting comments agree to the CIO comments policy.
Login or register to link comments to your user profile, or you may also post a comment without being logged in.
Newsletters
Sign up for our CIO newsletters!
Additional Resources
Syndicate content Syndicate content

URL
www.kyoceramita.com.au

Call us on
Australia: 1800 339 003
New Zealand: 0508 596 2732

Email us
marketing@kyoceramita.com.au

Did you realise that the cost or running a laser printer over its lifetime is likely to exceed the original purchase price by several times? To compare your current printer's running costwith a Kyocera printer, select the TCO Calculator

Total Cost of Ownership (TCO)
Kyocera Saves... Try our Saving Estimator now
Calculate Now

Testimonials

 
CXO Latest

Wondering how all this talk about the cloud relates to your business? Learn about the latest IT security challenges and how cloud-based email and web security can help save time, money and resources. Join Computerworld for a 30 minute live webinar to discuss how cloud computing can protect your organisation and combat threats from inside the network.

Wednesday 21 October 2009, Time 10.30 am EST (Sydney, Australia) Screening at your desk

Register

  • +

    Developer finds major coding errors in Facebook, MySpace 06 November, 2009 08:29:00

    The simple problems may have exposed users' data for an unknown length of time
    Social-networking sites MySpace and Facebook have apparently fixed coding errors that could have allowed an attacker access to all of their users' data and photos.
  • +

    Java, BlackBerry desktop get security bug fixes 05 November, 2009 09:25:00

    Sun releases critical update to Java Runtime Environment
    Sun Microsystems and Research In Motion have issued critical bug fixes for security issues with their products.
  • +

    Botnet authors crash WordPress sites with buggy code 05 November, 2009 08:58:00

    Other sites that use complex PHP are also affected
    Webmasters who find an annoying error message on their sites may have caught a big break, thanks to a slip-up by the authors of the Gumblar botnet.
  • +

    M86 Security buys Finjan 04 November, 2009 08:11:00

    Deal gives M86 a Web gateway security product
    Looking to strengthen its Web security product offerings, M86 Security has acquired most of the assets of Finjan, a seller of Web gateway security appliances.
  • +

    Software shields online banking on infected PCs 04 November, 2009 08:49:00

    UK security vendor Prevx says its software locks out malware during transactions
    A U.K. security company is giving to banks, for free, security software that it says can block malicious software from manipulating online banking transactions or stealing data, even if the computer is infected.

To find our more about joining your peers on the
CIO Executive Council email: cio_ec@cioexecutivecouncil.com.au


Upcoming Industry Events
Whitepaper

IDC Resource | IP VPN: The Key Enabler for an Optimised Enterprise ICT Environment

With the strong upbeat business sentiment on an economic recovery, IDC is expecting that IP VPN services – with multiprotocol label switching (MPLS) taking the lead – will increasingly become the technology of choice among enterprises. Read more now.

CIO Industry Insight Podcast #6: Brenton Smith, Managing Director, CA (ANZ)
Listen to the latest edition of CIO Live which is now available for download.
Listen to the podcast
Sign up to the CIO Live email
Whitepaper
Enterprise WAN Optimisation: Delivering faster applications to any user, anywhere

This white paper explores important acceleration technologies and looks at the specific issues behind application performance problems and how to resolve them within an ADN environment.

Read Whitepaper

Brought to you by