The simplest way of stating the speaker while writing dialogue in a novel is by mentioning his name first. Example: Bob said, "That's not very nice." When you identify the speaker after the quotation, the final sentence of the quote should end with a comma and quotation mark before explaining who's talking. Example: "That's not very nice," said Bob. If you choose to interrupt the dialogue with the explanation, the dialogue that follows "said Bob" does not take a capital letter. Example: "That," said Bob, "is not very nice."
However, every time you choose to include a "Bob said" or an "Anna explained," you are just wasting the reader's time. The speech and style of each individual character should be distinctive enough to recognize straight away. This is why a better way to identify the speaker without actually doing so is by including an explanation or identification at the beginning of any conversation, making it obvious that the two characters are completely different. The reader should be able to distinguish immediately who is saying what.
Some writers, either because they are afraid of not being understood or because they are doubtful of their reader's intelligence, might make their characters address each other in every line. For example "That's not very nice, is it Anna?" -- "I don't care, Bob!" Use this method occasionally, but try not to overuse it. Also, look at that last exchange of dialogue. The question marks and exclamation marks (just one of each) fit inside the quotation marks. They convey the tone of each speaker's line. And finally, if your characters are shouting at one another, then this should be clear from the content of the dialogue, not from the exclamation marks. Keep this in mind.
Another way to format the dialogue in a novel is by indenting the lines. The right way to indent your dialogue is doing this the same way as you would any other paragraph. A half-inch indent should be fine. Each time the speaker changes, you should indent again. So every time Bob speaks, he starts with a new indented paragraph. When Anna answers, you indicate this through another indented paragraph.