English is wonderfully ambiguous at times. To wit:
This is my friend, Sherlock Holmes.
If I said the above line, would I be (1) introducing a friend named Sherlock Holmes to an unknown interlocutor, or (2) introducing Sherlock Holmes to an unknown interlocutor who is a friend? The first option is appositive; the second is vocative.
In all likelihood, (1) is the more probable option because, had I been addressing Sherlock directly, it's doubtful I would have called Sherlock by his full name: addressing someone by his or her full name sounds unnatural. But that unnaturalness aside, it's conceivable that I might address my friend as "Sherlock Holmes," and if it's conceivable, then the appositive/vocative ambiguity legitimately exists.
When we speak of appositives, we're talking about expressions—usually phrases—that serve an adjectival function: they add a bit of information to a statement or other locution. Sometimes appositives are accompanied by commas; sometimes they aren't.
My best friend Mike is a budding terrorist.
In the above sentence, Mike is an appositive that adds information to the subject, i.e., the noun phrase My best friend. However, I could just as easily have written:
My best friend is a budding terrorist.
—and you'd have understood pretty much everything you needed to know about me and my best friend. Upshot: the appositive Mike, in this case, adds little to nothing to the core content of the sentence, so there's no need for commas. Here's a slightly different case:
Coriolanus Snow, the president of Panem, stared at Katniss with his cold, dead eyes.
The power relationship between Snow and Katniss doesn't come out unless you somehow emphasize that Snow also happens to be the president of the land in which Katniss is a rebellious citizen. This makes the appositive the president of Panem mightily important, which is why we set it off with commas.
Sometimes the comma/no-comma choice comes down to a question of style and/or emphasis. Going back to the "Mike" example:
1. My best friend Mike is a budding terrorist.
2. My best friend, Mike, is a budding terrorist.
I've already affirmed the correctness of (1), but (2) is also arguably correct if you, as the writer, deem it important that the reader know your friend's name is Mike. The point here is that (1) is not incorrect, so don't let anyone tell you it is. By extension, the "Sherlock" sentence that began this post can be rewritten without any commas at all:
This is my friend Sherlock Holmes.
And that's clearly appositive.
So much for appositives, which sometimes use commas. By contrast, vocative expressions, which involve addressing or calling people (hence the voca), always take commas, and I've ranted on them before, so I won't go into them again here.