There are, generally speaking, three kinds of dogs: aggressive, territorial dogs whose intention it is to chase you or bite you and show you who's boss, playful, excitable dogs who think that because you are riding by them, you must want to play a "chase me" game, and dogs who are very laid back and couldn't care less about you.
The first kind of dogs worry me most. Most dogs are somewhat territorial and they will chase you until the edge of the driveway but not actually run after you down the road. They will stop when they see you are leaving. But some dogs are badly trained or just plain mean and they will chase you with malicious intent for quite a long ways. I have never had to deal with a dog like this and I hope I never have to, though on my very first bike ride an aggreessive dog came at me out of nowhere and I nearly wiped out on some gravel. If I ever do encounter such a dog that has chased me beyond what I feel is a reasonable distance (not more than a couple yards, probably) or has forced me off my bike, then I wouldn't hesitate to physically hurt the animal until it backed off, if that was what I deemed was necessary. Usually, yelling at the dog, squirting it with water, or kicking at it will get it to back off. Dogs are pack animals and when a new person comes around, they like to show they are higher in the pack hierarchy than you so you have to show them that you are dominant and won't put up with their BS.
The second kind of dogs can also be problematic because they can be unpredictable. You never know if they will just stand at the edge of their driveway and bark uncontrollably and wag their tail until it nearly falls off or if they will want to run along side you. When I come up on dogs like this, I'll usually just unclip in case I need to get off and just yell at them loudly as I go by. If you yell at a dog, they'll usually realise you don't want to play and they'll think they did something wrong, tuck their tail between their legs, and sulk away.
However, a couple days ago, my bf and I were out riding when we spied a very excited (I swear he might have even been drunk) Coonhound running in circles in the middle of the road. As he saw us approaching him, he started racing towards us, wagging his tail and barking with glee, wanting to be all friendly and playful. No amount of yelling deterred him. When my bf squirted him with juice, it excited the dog even more. Finally my bf told me to just take off and I sprinted away as fast as my tired legs would carry me. After about a quarter of a mile, I look back and this dog is STILL chasing me, albeit a far distance off and my bf is following the dog. So I continued pedaling like crazy because I knew if I slowed down, he would catch up to me quickly. And I looked back again and my bf had passed the dog, but the dog was still on his wheel. I just couldn't believe how fast that dog could run and how much stamina he had. When a pick-up truck passed from the opposite direction, it distracted the dog from us long enough to get far enough ahead of him that he gave up. In cases like that, I guess there's nothing to do but outrun the dog.
Really, though, how you handle a dog depends on circumstances and what the dog is doing or what you think he is going to do. I usually try yelling at the dog first and if that doesn't work, then I'll think of something else. So I voted for the first option, even though I rarely have to stop and get off my bike.