Sex with an ex is bad unless there are ABSOLUTELY no feelings there anymore, and in that case, why would you be sleeping with him/her again? It almost always leads to trouble. Sex with a friend isn't the best either because no matter how you go about it, the sex does change the friendship a bit.
Take Austin Powers for example when Dr. Evil has sex with that other nasty looking chick.......things got "weeerd"
Anyway.......I'm of the opinion that people shouldn't be having sex unless they are both emotionally and financially prepared for the potential but very real consequences of their actions (pregnancy, STD's, etc.)
I never cease to shake my head when a friend calls me up totally freaked out because his girl might be pregnant and he's not ready for the stress. I just tell him/her that if you do the crime, be prepared to do the time, but people never seem to learn.
Abstinance is the key

(unless your partner is really hot! lol)