Dogs bark for a lot of different reasons. Some breeds of dogs seem to enjoy being more vocal than others, such as hounds, collies, Shetland sheepdogs, cocker spaniels and beagles. Others feel they must alert you to every possible danger such as the mailman approaching or just a leaf falling off a tree.
Some dogs are just bored. Being kept in the backyard all day long is boring and so they invent ways of keeping themselves busy. Barking is one of them. Other dogs are very stressed by being left alone outside all day (cast out of the pack's den). These dogs exhibit stress by barking, digging, chewing and general destructiveness. By making your dog more a part of your family, your dog will become happier and less prone to stress behaviors, including unwanted barking.
Outside stimulation such as neighbor's working in their yard, being teased by passersby, meter readers doing their job, etc., can also set your dog off barking each day. By bringing him inside to live, there is less to bark at.
What you want to teach your dog is that most of the time it is not acceptable to bark, such as in the dead of night or all day long while you are gone. It is OK for your dog to bark when you are playing ball with him or playing another game. IT IS NOT OK FOR YOUR DOG TO BARK AND LUNGE AT YOUR GUESTS! To allow your dog to do so is asking for trouble and Rover may soon take a bite out of them.
If you do like your dog to bark when people knock at the door, BUT YOU MUST BE ABLE TO CONTROL IT. If Rover has barked twice at your mailman, and you have told him "QUIET" and he has not responded to you, but keeps on barking, YOUR DOG IS OUT OF CONTROL! Work on the quiet command to alter this behavior.