Diverting Attention in Public
Once your dog notices the stranger, the best way to stop this is to calmly turn around and walk in a different direction, avoiding any chance of engaging. Keep treats with you, that way you can reward your dog after they have stopped barking.