In many cases dogs bark because they have nothing else of interest to do, a lack of attention can sometimes cause the barking. A lot of the time we give in to our dogs in order to make them behave, this only teaches them that barking will get them what they want which encourages more bad behavior. It's important to learn and understand the most effective dog training techniques so that you can effectively deal with this type of behavior.
Initially dogs nee to understand that barking just for the sake of attention is not acceptable. In many cases dogs will prefer "angry attention" over "no attention". This is not the ideal way to train them however. What you should be doing is saying what you want to say, and then backing that up by an action - typically something that the dog doesn't like.
Using negative reinforcement to stop your dog barking is one popular and effective method dog trainer use. An example of this is to say "Quiet" and quickly follow this command by squirting water at your dog. You dog will learn to associate the "Quiet" command with the water (most dogs don't like water being squirted at them). After using this method for some time you dog will learn not to bark without the need for a squirt of water.
If you should however, find that your dogs bark is accompanied by a growl and the look as though he may bite you, you may not want to threaten or use negative reinforcement, and instead you may want to consult a professional or your veterinarian.
If your dog barks often when you leave the house, a simple thing you can do is to make sure he has everything he needs to feel comfortable. Make sure food and water are available and that he has a comfortable place to sleep. Keep him away from windows as this may excite him and cause more barking.
Another thing you should watch out for is excessive praising of your dog. If you praise your dog too much, he will learn that regardless of what he does, he will end up being praised. When you teach your dog a new trick, or when you dog obeys your command, just give him a quick pat. Don't over praise him. Doing this will encourage more good behavior from your dog.
Also you will want to give him something fun to do when you leave, give some food, some chew toys and make sure he can't see others while you are away. Use negative and positive reinforcement with you dog, starting with the negative. Then when he has learned the activity and does it, then you can calmly praise the action.