There really isn't a way to prevent being heart broken but you can make it easier to get over.
Stop talking to the guy.
Don't be "friends."
Cut them off completely.
Give them back any stuff they left at your place....or throw it out.
Block their number because they WILL try to contact you.
Go ahead and take some time to grieve but don't wallow in your sorrow.
Go out with your girlfriends and have some fun. That doesn't mean you have to be on the prowl for another guy. Just go out and drink, dance, hike, run, whatever makes you happy!
Remember that you were happy before that dummy and you WILL be happy again!