This should be the easiest part of writing. After all, we learn to speak at a young age and practise that skill for the rest of our lives. Unfortunately it doesn't seem to work that way, the reason being that speech looks different when it is written down.
The key point to writing good dialogue is to make it as natural as possible. Normal conversation is not generally grammatically perfect. It is full of hesitations, repetition, um's and er's. Sentences are often left incompleted or hanging. However, you can't write dialogue like that and expect your readers to follow it. They will lose interest after the fourth 'um'. So you need to find the balance between perfect English and conversational English. The best way to do that is to know your characters and what they would say, and most importantly to listen to people around you.
The Purpose of Dialogue
Okay, obviously dialogue is used to communicate something (either to the reader or another character within the story) but the critical function of dialogue is to drive the plot forward. There is no room in a short story for unnecessary words. They must have a reason for being there. If they don't, take them out.
Dialogue is a crucial part of every character. The way they speak and what they say can be as revealing as a physical description. Be acreful not to let your own voice (the authorial voice) creep in. If you have something important to say to the reader, by all means say it through your characters but let it be in their voice. Readers do not like being lectured. Except when reading pages on writing tips, that is...
Dialogue alters the rhythm of a story. Short sentences without narrative increase the pace, whereas longwinded speeches may slow it down. When you reach a crisis in the story it is worth using dialogue to increase the tension, action or suspense.
Make it natural and keep it pithy. Try to avoid writing phonetically. It is distracting to the reader and sometimes unintelligible. If you wish a character to have an accent, simply tell the reader they have one. The rhythm of their speech will do more much to convey this than any oddly spelled words.
Who Said What and How
It is perfectly acceptable to use 'he said/ she said' in order to attribute speech to a particular character. Don't overdo it but remember that he/ she said becomes invisible to the reader after a while. Alternatively you can use other verbs, eg. she snapped, he drawled, she whispered, he murmured. A word of advice, use these sparingly. If the dialogue is well written it should convey how the words were said to the reader, without the need for any of the above.
Long periods of dialogue require the occasional indicator of who is speaking otherwise the reader may lose track. Once the reader has to backtrack and count the lines of dialogue to establish the identity of the speaker you have lost them. Slipping someone's name into the dialogue is possibly the simplest way of keeping readers on track. eg. you have Sam and Anna speaking, so every now and then have Sam say "...., Anna." or vice versa.
Try to get into the habit of reading your work out loud, or even better have someone read it back to you. Flaws in the dialogue will soon become obvious.
What is Style?
Style is the way you use words and sentences. Many new writers worry unnecessarily about it. Let your style develop naturally, don't try to force it. Everyone has style the moment they put pen to paper. The big question is whether it is a good or bad style and since this is often a matter of personal taste the simplest thing is not to worry about it. As a rule, the less obtrusive your style the better. If it can be flexible, even better. Different markets require different styles of writing.
The reader should be more interested in what you are saying rather than how you say it.
A Few Simple Suggestions
Keep your writing simple and straightforward. Say what you want to say in the clearest and most direct fashion.
Avoid long words if a shorter one is available.
Avoid cluttering your work with too many adjectives, adverbs, metaphors and similes. It is very tempting as a new writer to overwhelm your narrative with descriptions. Try to resist.
Make sure you have selected the right tense for your story and keep it consistent. All verbs must agree with the chosen tense.
Repetition of a word or phrase can be highly effective but try to avoid overdoing it.
Choose strong words. As a rule, these words have more specific meanings eg. oak as opposed to tree. Concrete nouns are stronger than abstract nouns eg. sunset versus beauty.
Wherever possible, avoid the passive tense. Have your characters do something, rather than have something done to them.
Vary your writing. Contrast will highlight the strengths. For instance, if the entire story is pacy, strong or dramatic, these qualities may be overwhelmed to the point at which they become weaknesses. Don't forget to vary sentence structure and length.
Above all, good writing should be fluent. Many factors contribute to the rhythm of a story. The easiest way to evaluate this fluency is to read the story aloud.