I make them sit, or do some heelwork with them to get them past anything. If I've got a tennis ball in my pocket, all I have to do is put my hand in my pocket and I'll get fabulous heelwork while they think there might be a bit of retrieving to be done.
What you haven't put is how you react to your dog's behaviour, quite important really. If you react by trying to console your dog in any way, or reassure them that the person approaching isn't going to do them any harm, then you are actually encouraging the barking and behaviour. Dog's don't understand reassurance, they know when they get it right because you praise them, so if you praise them at the right time for the correct behaviours then you leave them in no doubt
