Q. We have recently moved to a new development where there is a lot of new construction and landscaping still happening. I walk my 8-year-old golden doodle every morning through the neighborhood.

We have had her since she was 4 months old, and she is a happy girl who loves people, especially the kind with hands that can be used to scratch her. She is not a whiny dog that cries or whimpers at all.

On two occasions in the past 10 months, we have walked past some workers and she let out a little cry and walked away while looking back over her shoulder as if the devil himself was following her. The workers have done nothing except maybe reply “Good morning” as we pass.

Do you think one of the workers is a psycho killer, child molester, dog-eater or just a bad person and she senses it? It’s really got me freaked out. — Jennifer Aguirre, El Dorado Hills

Pet news, photos and more delivered to your inbox. Sign up now for the Pet Pal Connection newsletter!

A. This is a great question, and believe it or not, there’s been a lot of research done on the topic, so you know you’re not alone.

My dog, Bailey, for some reason has a bipolar relationship with my nephew, Dan. Bailey barks his head off every time Dan comes by, which is close to five times a week, acting as if I’ve let a mad hatchet killer through the door. Bailey tries to bite him if he gets too close, but if I hand him over to Dan, he wags his tail, allows himself to be petted and licks Dan’s hand.

This happens every single time, and Dan is the nicest man I know. He harbors no ill-will against Bailey, who would happily chew Dan’s leg off if he had the chance.

The experts offer a few insights into what might cause this unsettling behavior. The most common explanation is that our dogs are reacting on a memory of someone who did something bad to them. The bad person might resemble the good person physically or even by skin and hair color. They might even dress similarly, such as wearing a baseball cap or a jean jacket.

Whatever the case, it’s close enough in a dog’s mind that they react negatively, either cowering in fear or becoming aggressive.

What I find interesting is that dogs can react to others based on a sort of doggy morality. Several studies have been done around the world that have indicated that a dog can react negatively to people who have not been helpful to their masters.

In one study, the dogs watched people struggling with a task — using some tape from a dispenser. In some cases, the person asked for help and was given it by another person. In other cases, when the person asked for help, the other person turned their back and walked away. In the third case, the person didn’t ask and no help was offered.

Then the dogs, one by one, were offered treats. In the case where the person asked for help and was given it, the dog took treats from both people. The same happened in the case of the people who remained neutral. But in the case of the people who refused to help, the dog wouldn’t accept the treat.

The doctors who did the study concluded that dogs basically are born liking everyone and expecting them to be kind and helpful. When they encounter someone acting outside of that norm, they take a dislike to them.

You say you got your dog when she was 4 months old, but either something happened in those first few months to create a negative memory, or she has witnessed someone matching the description of the workers do something to you that caused offense in her mind.

Dogs are good at many things, but judging character might not be one of them.

Joan Morris is the pets & wildlife columnist for the Bay Area News Group. She also writes about gardening and is the founder of Our Garden, a demonstration garden in Walnut Creek. Morris started her career in 1978 as a reporter for a small New Mexico newspaper. She has lived in the Bay Area since 1988.