How to punctuate dialogue

One of the major things I notice when reading slush is that far too many writers can’t punctuate dialogue, so here is a quick & dirty guide that will help you in at least 90% of cases.

Consider the following sentences.

‘It’s OK,’ he said.
He said, ‘It’s OK.’

Notes:
I’ve used single quotes as standard in Australia, because that’s where I am. Many writers use double quotes, but I just want to be contrary. Both are acceptable and interchangeable. If your material gets accepted for publication, the publisher will change it to their house style.
There is a comma at the end of the spoken part. There can also be a full stop (see below) but you always need some form of punctuation at the end of the spoken section (= the part in quotes).
The spoken part and the dialogue tag (he said) are one sentence. The sentence would be the same without the quotes. In fact, some writers don’t use quotes.
A dialogue tag that is part of the sentence is never capitalised.

Now these examples:

He smiled at me. ‘It’s OK.’
‘It’s OK.’ He patted me on the back.

Notes:
Each of these examples consists of two sentences. The parts outside the quote are independent sentences because you cannot ‘smile’ or ‘pat’ a piece of dialogue; you can only say it, or shout it, or ask it.
Therefore, the punctuation you need at the end of the spoken part, inside the quote is a full stop.

But what if:

‘Are you OK?’ he asked.
‘That is not true!’ he shouted.

Because ‘asked’ and ‘shouted’ are still variations of speaking, you can treat them like proper dialogue tags, which means that they are not capitalised, never mind the question mark or exclamation mark inside the quotes.

But:

‘This is rubbish!’ He banged his fist on the table.
‘How would you do this?’ He flung the tangled mess of wire into her lap.

Because ‘banged’ and ‘flung’ are not speaking-verbs, they need their own sentence. Therefore the part outside the spoken text is an action tag, not a dialogue tag, and needs to be capitalised.