On Mi┼íko Hevery’s blog, there is a pair of fantastic resources:

This document is such a fantastic, succinct explanation of how to write code that will be easy to work with (and test!).

[I try not to make too many posts that only consist of links, but this is so good that I couldn't help myself.]