1. Have a clearly defined target; Before you do anything, you write up exactly what you are going to do, in as much detail as it takes for both you and the client to fully understand what it is that you are going to do.
Only once did I have a problem whereby what I did was not what the client expected, in order to retain the client I swallowed the loss, but ultimately it didn't work out between that client and I.
2. If it's a long term project, make sure that the client understands you'll be submitting evidence of work on a regular basis and that the client has x amount days to settle. If the client fails to settle within the time frame, the work ceases and should the client refuse to pay, you lose as little as possible.
3. Trust your gut; if you feel something is wrong with this client or they start badmouthing other developers, walk away. IMHO it's the clients who act unprofessional who're going to treat you poorly.
@Greg OLone First, make sure you have a contract with a clear payment schedule included. Lawyers love those.
Absolutely; always have a contract that explains your terms and conditions. However as someone who's gone through the legal system more times than I should have, unless the contract is worth 10s of thousands and the client owes you that much money, it's not worth it. The legal fees can cost more than you'll ever receive. Worse yet is winning and then the client is not only broke, but has no tangible assets anyway (which is what happened in the last legal case I was involved in).
Best bet IMHO is to be on the defensive; never put yourself in a position where a troublesome client can take advantage, follow everything up in writing with clear descriptions.