Positive dog training is based on a principle – if you reward and praise a dog for behaviour the dog is more likely to repeat it and offer it to you. A lot of misbehaviour – aggression, biting or barking stems from fear and timidity. So pulling on a collar, and scolding your dog when they bark at a man with a hat because your dog is terrified of those hats, is making things much worse.
With your impatience and harsh treatment you only confirm, that the dog has to be fearful of hats because whenever your pup sees a hat and tries to warn you, you shout at the dog on pull on a lead causing an unpleasant sensation. Be patient and ignore unwanted behaviour or redirect your dog’s attention to other things like a toy, a treat or change a walking direction.
Do not forget to praise your dog also when they do not react to a passing cyclist or a ball bouncing nearby. Even though you take it for granted that a dog should not run away and catch the ball, it is against your dog’s instincts to stay non-reactive to a fast-moving object.