Fowler on refactoring

jplindstrom on 2004-10-07T10:49:39

Nothing new, but I think this neatly captures what refactoring is all about:

The whole point of refactoring is that it improves the design of existing code. The value of well designed code is that it is easier to change. Hence you refactor code that you expect to change in the future.

This leads to the practice of refactor-as-you-go. The second most useful time to refactor *) is just before you change something, both to become familiar with the code and to make the implementation easier. This is also a great time to improve the test coverage, because you know what you're about to possibly break.

*) I'd say the most useful time to refactor is just after you wrote somehting that obviously needs cleaning up.


The second most useful time to refactor

dws on 2004-10-07T16:09:29

Refactoring can also clear a path for new development. What looks cleanly refactored after on development episode can look like a field littered with obstacles when a new set of development stories gets picked up.