Critical.
Authoritative.
Strategic.
Subscribe to CIO Magazine »

Code Of Practice

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.

Join the CIO Australia group on LinkedIn. The group is open to CIOs, IT Directors, COOs, CTOs and senior IT managers.

More about: Aberdeen Group, Addison-Wesley, ADVENT, Agile Software, Billion, C2, Carnegie Mellon University, CGI, Forbes Magazine, HIS Limited, IBM, John Wiley & Sons, Mellon, Microsoft, Oracle, Sabre, Speed, Suncorp, SUNCORP-METWAY, ThoughtWorks, TurnAround Solutions, University of Queensland, University of Queensland

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
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.
Related Whitepapers
Latest Stories
Community Comments
Latest Blog Posts
Whitepapers
  • Managed Services Strategy Guide
    If you’ve heard the term managed services mentioned in relation to a broad range of different services, you could be left wondering what the phrase ‘managed services’ actually means. In simplest terms, managed services are any aspect of your business that you outsource to a third party to manage. This Computerworld Strategy Guide will review outsourcing options available and outline how managed services can help to reduce running costs for different aspects of your business, in turn increasing profitability within your business.
    Learn more »
  • High Availability with Oracle Database 11g Release 2
    This white paper reviews the common causes of application downtime and discusses how technologies available in the Oracle Database can help avoid costly downtime, enable rapid recovery, and minimise impact from planned outages. Read on now.
    Learn more »
  • Smarter Storage and Data Management for Virtual Server Environments
    There is a huge transformation happening in IT organisations, migrating from single-purpose physical servers to consolidated virtual machine technologies. The benefits of virtualisation are many: cutting acquisition, management and facilities costs by reducing the number of physical machines; increasing service levels through faster server provisioning; and enabling new delivery models such as cloud services. However, virtualizing servers does not reduce the amount of data that is created and stored; actually it can have the opposite affect as virtual machines are moved or de-provisioned. IBM provides advanced data protection and flexible recovery capabilities for VMware, addressing data management challenges.
    Learn more »
All whitepapers
rhs_login_lockGet exclusive access to Invitation only events CIO, reports & analysis.
Recent comments

HP and IDG news, product videos and resources