In a post called The Life Changing Magic of Tidying Up Code, Kent Beck outlines his philosophy on cleaning up code. The article results in a short list of easy-to-follow rules, which I'm sure he would agree are there to be broken.
- If it’s hard, don’t do it
- Start when you’re fresh and stop when you’re tired
- Land each session’s work immediately
- Two reds is a revert
- Isolate tidying
What To Tidy is a follow-up post in which Kent goes on to describe specific patterns to look out for.