http://qs321.pair.com?node_id=239456


in reply to Bad Practice

I'm just now getting into it, but one of the practices of Extreme Programming (dorky name, but good ideas) is constant refactoring of code. (Must use more buzzwords!) Basically, when you see a bit of code that could be made clearer or that, if changed, would make it easier to add the new functionality on which you are working, you do so.

However, you should only do the refactoring if you have unit test cases that you can run to verify that your changes didn't break anything. In addition, you should do the refactoring of the old code separately from adding the new functionality, so that you can know whether any problems shown by the unit test cases are the result of the refactoring or are the result of the new functionality.

In short, improving code is a good thing, so long as you can verify that the improved code works as well as the old code.

Wally Hartshorn

(Plug: Visit JavaJunkies, PerlMonks for Java)