Dialogue is not just quotation. It is grimaces, pauses, adjustments of blouse buttons, doodles on a napkin, and crossings of legs.
~Jerome Stern, Making Shapely Fiction, 1991
As writers, we don't want to write the way people really talk. Real speech is full of ums and ers, backtracking and repetition, and telling people things they already know. Trust me, I know this, having spent the last year transcribing audio interviews into text format. But on the other hand, unless your character is a British school boy, he's not going to speak with perfect English either.
What you want to do is give the impression of how people really talk. This is the one time you can get away with sentence fragments and comma splices, idiomatic and clichéd phrases, as well as intentional misspellings that indicate region, ethnicity, or class.
Keep in mind the age of your character when they're talking. A six-year-old will sound much different from a sixteen-year-old, who will sound quite different from a sixty-year-old. And a mid-west farmer is not going to talk the same way as Wall Street investment broker.
Avoid drowning your dialogue in character tags - phrases such as exclaimed, murmured, shouted, whimpered, asserted, inquired, demanded, queried, thundered, whispered, and muttered. In most cases, the word "said" works just fine, and using colourful tags detracts from the dialogue. I once read a novel that had no character tags whatsoever in it, and I never missed them.
If you're a romance writer, one dialogue tag to avoid, "He ejaculated." At the very least, don't use it during a sex scene – unless you want a laugh. And don’t let your hero say something ‘cockily’ either. Laughter is the surest way to ruin the ambiance of a passionate love scene.
Watch the adverbs in your dialogue tags as well. If a character’s words are already angry, you don’t need to insert the word angrily after she said. It's far better to show the character's mood with his or her actions.
"This is unacceptable," she said angrily.
She slammed the book down. "This is unacceptable!"
I once wrote a short story that was almost entirely dialogue. The two characters were talking on the phone the entire time with a non-speaking paragraph at the beginning and another one at the end. To be perfectly honest, while it was an interesting concept, the story fell flat because all the characters did was talk.
Don’t have your characters just standing, or sitting, across from one another rambling on and on. Have them emphasize what they’re saying with their hands. Have them move around – sit down, stand up, pace. Be aware of their facial expression, especially the eyes. Have your character pick up a book, crumple a paper, put their fist through a wall. The items in a room can be fiddled with, gestured with, tapped – they put a static character in motion. Characters should never sit still unless the stillness important to the plot.
Dialogue should always have a purpose. Most often that purpose is to relay important information, but it can also increase suspense, clarify what a character wants, strengthen (or weaken) their resolve, or even change their situation for better or worse.
Above all, dialogue should move the story forward.