Put both names on the lease or mortgage. If you are going to break up but still live together, have both names on the lease so neither person can leave the other high and dry with the payments. Each person should pay half of the living expenses.
Stop sleeping together after the breakup. This means completely--no sex. If you just want to be friends, be serious about it. If there's any middle ground, emotions will get involved and it will be a failure. Have your own bedroom and sleep in it.
Be courteous to each other's friends. Since you are no longer dating, there is no need to be concerned about where the other person is going and when he will return. This can be the most difficult part of breaking up and still living together. Keep yourself in check by having your own activities away from your former partner and your own independent friends.
Talk about what you are going to do with future relationships. Set boundaries and rules together. This is a very touchy subject, which is why it's important to discuss it. Determine whether you're allowed to bring dates home and how the other person should act when that happens.
Live up to your end of the deal. If either party fails to follow the guidelines, the entire household fails. This isn't a normal friendship and roommate relationship, so don't treat it as one. Both sides need to understand that they need to make extra effort not to lead the other on and be sensitive to emotions.