A consulting philosophy based on the movie "Heat"
The Software consulting world is full of horror stories on both sides of the table: Incompetent developers. Payment never issued. Buggy software with embedded backdoors. AWOL Developers. Any horrible situation you could imagine has happened and been documented somewhere on the Internet.
As a consultant you learn to steel yourself to the possibility that the next client could be an absolute disaster. You try to pick up cues during the initial meetings as to the mental state of the potential client and their level of truthfulness (they are doing the same when they meet me).
But no matter how good you are at reading people, there's always the chance that a client or project will slip through your filter, making any chance of a successful completion and/or compensation impossible. A lack of proper execution on the developer's side can obviously be a cause, but there are plenty of reasons this can happen on the client's side - a lack of understanding of the problem space, unrealistic expectations, changing requirements, lack of funds, outright fraud - just to name a few.
There's only one real way to prevent yourself from getting burned and burned bad: get a really good lawyer and make sure everything you do has an ironclad contract to back it up. The belief being that should something go wrong, you'll have proper recourse to recover compensation.
But I don't think anyone believes that it's simple. Lawyers cost money, take time, and waste mindshare. For smaller consulting projects, going to court to settle a dispute just isn't all that practicle.
Even more important, as we learned a few years ago, is that some people are simply batshit-crazy. When a situation goes south it can go south in a hurry. And some people really like a nasty fight, with all the word-gouging and fraud-tossing it involves. If you're not one of those, and I'm guessing most developers aren't, regardless of whatever is in the contract, you probably won't be willing to stoop to that level for the prolonged battle necessary to get compensated.
A better philosophy, and the one we now follow, could be summed up with a line from the movie Heat:
"Don't let yourself get attached to anything you are not willing to walk out on in 30 seconds flat if you feel the heat around the corner."
Now, before you get too angry, let me explain: I'm not espousing a philosophy of dropping projects and clients the minute something gets difficult. Not at all in fact.
I'm saying you need to make sure, that at any given point in time, the amount of money owed to you on any one project by a client doesn't mean so much to you that you couldn't walk away, if it came down to that. This means that if you're working on a large project, you need to make sure that you have compensation set up in such a way that a client can't put you in a situation, where you have no other recourse besides legal action or capitulation.
Since account payable departments (especially in large companies) have the habit of not paying bills on time - you'll need to both stay on top of your billing and be willing to put a hard stop on a project, if you're not being paid as specified in your contract.
Waiting to be paid for ongoing work for two weeks is very different from waiting for two months. Once you let it slide for too long, you'll be digging yourself further and further into a hole to the point where you'll be without any wiggle room if things go south.
The situation you want to avoid is that of a gambler who keeps risking more to try to get back to even money. Human beings have a strong impulse towards loss-aversion. Once a project goes from a positive experience to one where you're trying to avoid losing money you've already banked on, your behavior on the project will change to avoid that loss. You'll resent working on the project, but feel like you have no choice but to get it to a point of completion so that you can get paid. Your work will suffer, but you'll be caught in a situation similar to our unlucky gambler, without a lot of easy options.
If, on the other hand, you are able to absorb whatever the lost revenue from the project would be you can have a sane, reasonable discussion with your client. And you won't feel that you have to put your house into the pot.
The "Heat" consulting philosophy helps you avoid situation where you have to spend unnecessary time, money and mind-share just to recover compensation for completed work.