ALL DOGS BARK, it's a natural thing for a dog to bark and should not be discouraged when it is appropriate, i.e. when a stranger comes to the house, or if the dog hears out of place noises during the night. At these times your dogs bark is a welcome and reassuring warning. So you should only be training a dog not to bark at the wrong times.
However a dog that continually barks for no apparent reason can become a bit of a nuisance, both to you and to your neighbours. So training your a dog not to bark, should be a part of your overall dog behaviour training. Any random or nuisance barking should be stopped as soon as possible, preferably when the dog is still young, as it will become harder the older the dog gets.
If you are with your dog when it starts barking for no apparent reason, simply tell it to stop. The actual words or commands you use will not matter as long as you always use the same commands, and say them with authority. If this fails to have any effect, then try saying the commands while at the same time giving a quick jerk on its collar or leash. And remember to quietly praise him or her when they obey.
Solitary barking is when your dog barks when no one else is at home. (Or when it thinks no one else is at home.) It will often bark incessantly, if you have close neighbours and your dog is one of these, then you will soon know about it, as you will no doubt receive complaints pretty quickly. This type of barking can be a real nuisance and you should try to stop it right away.
One way of stopping a solitary barker is to pretend to leave the house, wait for it to start barking, and then quietly return and catch it in the act. Reprimand it with the same commands or phrases that you used before, and again quietly praise them when they stop. Doing this a few times should soon stop your dog from being a nuisance every time you leave the house.
You should try to stop your dog from becoming a solitary barker before it develops too far. You can easily do this with a few simple tips, such as getting it used to being alone gradually. Try going out just for short lengths of time to start with, and building up to longer and longer periods. You could also try leaving a radio on in the house for company, and make sure your dog has its favourite toy.
A dog is part of your family and should be shown the love and respect that it deserves. By training a dog not to bark at the wrong times, as part of a dog behaviour training programme, you are helping it and yourself to a more fulfilling and rewarding relationship that will last for years to come. (And you will probably get on with your neighbours a lot better as well.