I don't quite understnad where you ride to get attacked bya dog. All our dogs are at home in the back yards surrounded by stone walls.
I have three dogs and one of the is a Rottweiler. None of them are even closely interetsted in a cyclist - this is how they were trained. Any dog responds to a firm and strong "NO". There is no reason to hurt the animal.