It can work, for some relationships, and some people. For others it will be a painful disaster.
It has to be completely mutual. Both people need to want to be friends - if one person is pushing it, and the other is just giving in because they think they should, or they don't want to look petty, the results will be bad. And it's not uncommon for someone to 'want to be friends' as a way of hanging on to a relationship they don't want to end.
Both people have to be completely over the relationship. They can't be harbouring resentment over the breakup, or still in love with their ex. If there are still feelings, trying to be friends makes getting over the other person a long, drawn out affair, where every sign of friendship or attentiveness is seen as proof that the other person wants them back.
And it takes time after the break up, both to get over the feelings of the breakup, and to reset to friendship mode rather than romantic mode.
As a test - if you can watch your ex cuddling with a new partner and be happy for them, you're in a good state to be friends. If you're jealous, or angry, or sad, then you need more space and time before you're ready. And if you were friends before you dated, then the friendship after you've dated will be different - you won't get the same thing back.
If the relationship was one with a big imbalance in power - one person tended to call the shots, or control the relationship - then trying to be friends is likely to perpetuate that imbalance, and will be unhealthy for the person who is on the controlled end.
If it's a case where you're going to be seeing an ex regularly, professionally or in the same social circle, then polite but distant works well, and you can see how things progress. It may turn into a friendship, or you may just be casual acquaintances/co-workers.
ETA: I also find that it's important that you respect your ex as a person. If a breakup was due to differences in personality/style/lives/goals, or complications of life, or just not feeling that way about each other, but you still respect the other person, then friendship has a better chance. If you don't respect them - if they cheated on you, or otherwise treated you badly, say - and you think that they are not a very nice person, then you shouldn't try to be friends.