The boy scout rule

When you leave the camp, leave it a bit better than you found it . From this presentation (which I found interesting, but very annoying at times, and the beginning is simply too silly)(via Victor Hurdugaci). Which applied to code is:

Leave the code you fix a bit better than you found it. Fix one small thing or two. Rearrange some code. make it work a bit better.

I think it’s an incredibly good piece of advice – bugs usually creep in badly written code – and by fixing badly written code whenever you see it you might fix a bug before it appears.