Archive for May, 2007

AiS 24: Refactoring

Wednesday, May 2nd, 2007

Listen Now

Refactoring is the process of changing the structure of code without changing its behavior. Martin Fowler coined the term when he wrote the book on the subject. Not only does the book define refactoring and describe when to use it, but it also provides a catalog of recipes for refactoring code. By iteratively applying these transformations to a system, Fowler says that you can evolve the design of existing code.

I use refactoring in my day-to-day coding, but not in the way that Fowler recommends. I design my software systems up front. I don't expect the design to evolve into a good solution. However, I will often use the automated refactoring built into tools like Eclipse as a way to edit code. The tool is a faster typist than I am, and it won't make a mistake due to a copy/paste fumble.

Refactoring, as most agile development techniques, works best when you have a small team of talented developers working in uncharted territory. Agile techniques move the methodology out of their way and allow them to be talented. However, if you know where you are going, it is much better to draw up a plan to get there.