"Bark...Who Goes There?"
So...what, if anything can you do about the barking if it's something you wish you curtail? First and foremost, don't punish the barking behavior because it will not work and may even make the behavior worse.
Consider the following four general areas of your dog's life that may need attention:
Health. See a veterinarian rule out any physical problems that may be causing the barking.
Environmental Enrichment. Dogs are social creatures and need an enriching environment filled with toys, games, and activities to keep them busy, happy, and quiet when alone.
Leadership and Training.
Management in General. Determine the circumstances or triggers that most likely generate the barking and find ways to remove the temptations.
Stay calm, yourself. Don't punish "joy" but also don't give attention to the behavior. Give the dog something to hold in his/her mouth, or ask them to "fetch" something, or ask for them to "sit" for just a few seconds if they're agitated only a little. Reward the pup for his/her silence
Let the dog know you heard him and are in charge and that you are taking charge over the responsibility to act against whatever he perceives as a threat
Avoid whatever is making the pup afraid. Remain calm and don't act afraid yourself. Don't pull or force or coax a dog into a situation he doesn't feel safe. Go between the dog and the scary thing or curve away from it. Gradually introduce the pup to scary things and attach good things to it like treats to change his emotional response.
Planning, thinking ahead, and management of the environment are the keys to preventing guarding behaviors. Parallel walking with other dogs and people that the pup has a problem with. Walking a curve past approaching dogs/people that are triggering the dog. Change the association the dog has with the object by praising and rewarding calm behavior in the presence of the objects.
Remove the dog from the situation that is increasing the frustration. Give him something to do. Let him be part of the family and give him the chance to use his senses by sniffing and exploring, this will give him the mental stimulation he needs
Ensure the dog does not get a chance to do the unwanted behavior by taking away the possibility he will react by barking. Start training the dog to have a different response than barking.
Seek out the services of a certified dog trainer, or a board-certified veterinarian behaviorist for any of these behaviors if you need help changing your pup's behavior through as positive an approach as possible. You can speak to your veterinarian for a referral or look online at the Association of Pet Dog Trainers, or the International Association of Animal Behavior Consultants website.