Dialogue can make a piece of text more interesting to read, for a variety of reasons. Firstly, it can make the reader feel as though they are there at the scene themselves, eavesdropping on the conversation. It doesn't matter whether the scene is a piece of fiction, or an interview in an article, using dialogue allows the people in your writing to talk directly to the reader, rather than you, the writer, recount secondhand what was said.
Dialogue also benefits a piece of text by breaking it up on the page and making it easier on the eye for the reader.
But as I was marking a few assignments over the weekend, I noticed that there appears to be some confusion concerning punctuation and dialogue.
When using dialogue in a piece of text, you must always have a piece of punctuation before the closing speech marks. If the speech or quote is part of a longer sentence, then you use a comma, before continuing your sentence, like so:
“The weather is absolutely barmy today,” he said, as he found some shade to sit under.
(NOT "The weather is absolutely barmy today", he said, as he found some shade to sit under.")
If your piece of dialogue is the end of a sentence, then use a full stop, or other final punctuation mark, like a question mark or exclamation mark, before the closing speech marks.
Sitting under the tree for shade, he said, “I can’t believe that it can get any hotter.”
(NOT Sitting under the tree for shade, he said, "I can't believe that it can get any hotter".)
If your dialogue is a complete sentence in itself, again, the punctuation mark goes before the closing speech marks.
"What the blazes is going on here?"
Never have a space between the punctuation mark and the closing speech marks, because this may confuse your word processor to insert opening speech marks, not closing speech marks.