There are many different situations in which a dog barks. There are ways to manage the situation to get your dog to stop barking, like closing the shades so she stops barking at passersby. But usually the situation is not manageable and you need to do more than removing the motivation.
First of all, you don’t want to yell at your dog to hush – to them, it just sounds like you are barking right along with them! As hard as it is to do, you have to ignore the barking, especially if your dog is barking for attention.
The technique to use is really quite simple, but it requires a ton of patience and a lot of time, but it works. While it may sound like your dog is barking continuously, he does have to stop to at least take a breath, and usually stops to listen if his barks are being responded to. At those moments, however, brief, say “yes! Quiet” (or use a clicker) and treat your pup. The timing is critical, so be certain to get that “yes! Quiet” in quickly – the reward does not have to come immediately, but the “yes! Quiet” does so he knows something good happened and is about to happen. You also have to time it so your dog thinks he is being rewarded for the quiet and not the barking.
Example of procedure – Assume your dog is in his crate or pen and starts barking for attention. You should turn your back and ignore him. Once he stops barking, turn around, say “yes! Quiet” and treat him. Eventually, your dog will come to understand that barking is getting him nothing but being quiet is actually really cool. As your dog catches on, vary the treating by the length of time your dog stays quiet. As time passes, like weeks, you should be able to interrupt your dog’s barking by saying (not yelling) Quiet. When she becomes quiet, say “yes!” and treat her. As more time passes, you can remove the treating every time but do it like a slot machine, pay out randomly.
If your dog is barking at a stimulus (the thing that is making him bark), move him to a spot far enough away where he stops reacting. It may have to be really far away or just a few yards away, but you will find that threshold line. Once you get to that point, feed him lots of high-value treats. Keep your distance from that stimulus. If it moves closer, you need to move your dog further away, and vice-versa. If the stimulus moves out of sight, stop feeding your dog the treats.
This process has to be repeated many times before you can consider moving your dog closer to the stimulus. Once you feel your dog is ready, move a little closer and rinse and repeat with the treats. Eventually, after weeks of this process, you should be able to get much closer to the stimulus without your dog reacting. But if he does react, be patient, move your dog a little further back and rinse and repeat. Sometimes you have to take a step back to move two forward.
One last note – sufficient exercise usually corrects 70% of dog behavior issues. Also, before starting this training, make sure your dog is hungry for treats.