Sunday, June 19, 2005

Code refactoring and cleaning out the garage

My wife and I did a major garage cleanout this morning. We have a general rule: anything that has not been used for a year or two years goes to the Good Will charity (or the recyclers, or the trash - in that order). The same rule is not so bad for software systems also :-)

I made a small mistake recently while refactoring code in a large system written by other people. Refactoring is a functionality-preserving activity. It is usually a mistake to try to add functionality while refactoring; rather, we should make small changes with lots of intermediate testing in order to minimize debugging time (i.e., make one or two changes at atime, and is is more obvious what caused a new bug). I added some functionality to the system that I was refactoring and in the end, I think that it took me more time than breaking this process into two pieces: refactoring, then adding functionality.

No comments: