Great Dialogue Begins With Characters
First, really get a good sense of your characters, their motivations, their nuances, their quirks, their voices. Good writers, in some cases, can write dialogue with no tags (Dan said, Molly said). If their characters are fully realized, it's possible to know who is talking simply by what they say and how they say it.
Be Your Own Thespian
Role play the scene you're writing to see if it flows well. Grab your roommate, husband, wife, or crit partner and *run through your lines* like you're rehearsing a script. If it flows naturally... roll with it.
Part of this goes back to dialogue tags. If you can discern who is talking without a dialogue tag (he said/ she said) then telling *who* said it is redundant. Also, try not to repeat things previously said. There's nothing more annoying than a dialogue echo. Echo. Echo. Echo
Use Dead Spots In Conversation
Sometimes there are actions that eat up dead space. Non-verbal communication is just as important in writing dialogue as it is in real life. Use them to your advantage. For example, consider a convo between a mother and daughter about the daughter's report card.
Mom: "So, Marilu, do you have anything you want to tell me about this F in Chemistry?
Marilu cast her eyes downward, continuing to spread mayo on her sandwich.
Mom: "Did you hear me?"
Marilu nodded without looking up.