A housefly bases its sense of direction on the direction
sunlight comes from. Some entomologists believe that when these complex eyes experience refracted light, the insect becomes confused and flies away.
I ate at a restaurant the other day that had ziplock bags filled with water to which one penny was added (to keep the water looking clean). They tied off the top and hung them with strong string from rafters on their outside patio.
I had just eaten at this restaurant a few weeks prior and fought off flies the entire time. On this visit, not one fly came around. It worked so well, I made some water bags to hang outside my back door. While find their way inside my home, I don't have the big problem with them that I did before. Check out a picture
here.