I won't direct you to another node. I'll direct you to 2000 words that I've already written on the subject, oft referenced:
a column of mine from a few years back. You'll find basic strategies, guidelines, and about 50 lines of sample code. Use it. Learn it.