I'm a strong advocate of the 'Clean-Break Policy', which means that ALL CONTACT with your ex, as soon as they become your ex, must be completely CUT OFF. And preferably, you'd have had your own separate groups of friends, so you won't ever have to worry about awkward social situations or having to navigate the shady business of dividing loyalties between those mutual friends. This has always worked for me, and I stand by it. I've seen too many friends get 'strung-along' by an ex, who would always seem to revel in keeping my friends 'on the hook' for nothing more than their personal amusement.
BUT-- the one situation where I did 'hook-up' with an ex did result in some AMAZING SEX! We had decided to 'take a break', or put the relationship on a temporary hiatus, as we mutually agreed that things had just gotten boring between us. So during this break, we 'hooked-up' 3 or 4 times, and they were definitely among the BEST sexual encounters we had during the entire time we knew each other! She met someone new a few weeks later, so I cut-off all contact at that point.
So YES, 'Sex with an Ex' can be good"
Fighting the Good Fight...