Dogs don't just attack for no reason with no warning.
Being in the vicinity of their territory is enough reason for some dogs, and the fact they may "warn" you by barking or chasing you before they bite doesn't necessarily mean you can get away.
As a child I was quite good at dog psychology, the only time I can remember being bitten was when an Alsatian chased my bike as I was riding past his house and I couldn't stop fast enough to deal with him.
Dealing with dogs means using dog psychology gained by experience. Look into his eyes briefly and admonish firmly but unagressively, then look away and walk slowly on, turn and repeat a few times until they stop following you. This is in the street: you shouldn't be in a home/garden that contains an aggressive dog in the first place, if the owner isn't there.
The looking away I learned from something I read as a child: if you stare to long you will come across as challenging/aggressive, which will provoke them.
The non-aggressive tone and the turning away (while keeping watch out of the corner of your eye) helps to convey that you regard him as an irritation rather than a threat. If he thinks you're not afraid him of he is discouraged from attacking.
Wouldn't want to try my dog psychology on todays pit bulls though - that sort of dog and the type of person who keeps them were not around when I was growing up.