Barking is the way dogs communicate. Understanding why dogs bark is the first step to finding a solution for problem barking. Dogs bark for 3 primary reasons. 1. they are bored; 2. they are sounding an alarm that they’ve detected unidentified sounds, movements, or odors 3. they are nervous or frightened (some dogs are extremely afraid of being left alone, a condition that is often referred to as "separation anxiety").
If the dog is barking because he’s bored, you often can tell because the dog will sound bored, woofing in a somewhat rhythmic and monotonous way. Basically, these dogs are generally ones that spend their days alone; they are barking to kill time. The solution is to make your dog’s world more interesting. Spend more time with the dog and give him more exercise. If you know you’ll be out for a while, give the dog entertaining toys such as a Kong filled with peanut butter. Tired dogs bark less and a dog can’t bark while he’s chewing.
If the dog is "alarm barking" the behavior was likely reinforced when he was a puppy. Scolding a dog or puppy for barking reinforces the behavior because the dog has gotten what he wanted: your attention. It may not be good attention, but to a lot of dogs any attention is better than none. Some dogs also seem to view people yelling at them for barking as just humans joining in the fun. Solving the problem usually involves distracting the dog and redirecting his behavior. For example, you might clap your hands then ask the dog to sit every time he barks.
If the dog is barking because of separation anxiety, you need to gradually teach him it’s okay to be alone by leaving for short periods and praising him when he behaves upon your return. Separation anxiety can be a complex problem that manifests itself in many ways, so if you think that is the problem, you may want to talk to your veterinarian, a trainer, or behaviorist for advice.