Monday, July 28, 2008

More on Refactoring

I am the first to admit when I am wrong (well, at least one of the first.) I was a huge advocate of "slash and burn" coding (where you delete all the old code and rebuild from scratch.) There are still times when that may be appropriate, but I will be a lot more choosy with it in the future.

Currently, I am in the process of refactoring one of our game systems to be simpler and easier to use. I started off with the idea of "slash and burn", but with the lack of time I had to work on it and the lack of progress, I was forced to roll-back my changes and try a different approach. The approach I took is to go one step at a time. I started off by picking one thing and fixing that in the code. Once I had that working, I picked the next thing and got that working. Today, I managed to factor out two different classes that were not really needed and greatly simplify the architecture. Tomorrow is the last day I have to work on the system and, although I won't get everything done that I wanted, I will have at least made progress. And ultimately, progress is what matters.

Seems obvious, but it is easy to get caught up in the rush of doing something new. It is important to know when to rewrite and when to refactor.

No comments: