Paul Gielens:ThoughtsService

another Endpoint to my thoughts






Refactoring is Not Free

In my post Agile but Not Quite Yet Frans made the following comment:

One of the key mistakes embedded in agile development is that it assumes refactoring is free. Let me tell you: it's not, far from it. Especially in OO systems where refactoring of designs can lead to severe delays of the project as a whole, it's key to know as much information about the functionality you have to realize with the software you're supposed to be writing, UP FRONT, so you have the best chance to have the 'best' design in the first attempt.

With Frans not being the easiest guy on the planet to convince… and although he has a point…

Refactoring doesn’t add features nor fix any bugs. Refactoring improves the design of existing code in order to make it easier to change. So yes refactoring isn’t free when the application will never change, because you’ll never get the payback. Concluding change is the driving reason to refactor.

A couple of months ago we where up for the challenge to refactor a large portion of a badly performing application. The application had no supporting unit tests, cruddy code and Swiss cheese specifications (its developers only had a sense of what the application had to do). It is in this example where refactoring became costly. At start we tried to cover as much existing code possible (see Improving the Testability of Legacy Code using TypeMock.NET). Although the confident level increased we weren’t able to preserve the behavior of the code while refactoring small pieces at a time. Eventually we had clear signs that the progress we made just wasn’t enough. We then decided to rewrite it from scratch and than refactor it.

Thoughts and/or experiences to share?

Posted: Dec 04 2005, 11:47 AM by p.gielens | with 15 comment(s)
Filed under:


No Comments