Don't Trust Anyone, Least Of All Yourself

Part of https://discourse.jujucharms.com/t/read-before-contributing/47

Don’t Trust Anyone, Least Of All Yourself

Whether through negligence, through weakness, or through their own deliberate fault, our collaborators will do strange things. Maybe they’ll close a channel they swore they wouldn’t; maybe they’ll call methods in unexpected orders; maybe they’ll return invalid data without an error.

The only thing you can be reasonably sure of is that you will be abused by a collaborator, directly or indirectly, at some point; and you’ll probably be responsible for inflicting your own weirdness at some point. The traditional advice is to be liberal in what you accept and conservative in what you emit; in this scenario, with potential chains of dependency running from component to component across the system, it’s safest to be conservative across the board.

It’s much better to fail early and loud when you see the first warning signs than it is to fail late when the damage is already irrevocable.

And about not trusting yourself: just because you’re writing the code on both sides of the contract, don’t kid yourself that you’re safe. The next person to change the code won’t remember all the implicit rules of sanity: if you’re not enforcing them, you’re conspiring to break them.