When my dog barks, I will look to see why. I then tell him 'Enough', and tap him on the nose. You don't need to hit them, just a light tap. If they do not stop, repeat the steps. Praise them when they stop. They will get the idea and every time you say 'Enough', they will quit barking. I have always trained my dogs that way and it has even worked on yappy breeds.
Look for a reason when they bark. My mom found the dog in the kitchen barking at the refrigerator. She found out that my dad had been putting ice cubes in the dogs water dish and she wanted an ice cube in her water.