Flies reproduce (lay eggs and hatch) in a wet, warm environment. Keeping the environment as dry as possible helps.
And, the critters are brought in on stuff like banannas.
I've not found the bleach solution works well for a fly problem. But, what did work were bags of water hung everywhere.
I couldn't figure out where all our flies were suddenly coming from since going the extra mile to keep the critters at bay was done here on a daily basis. Then I learned a neighbor was dumping his sewage out in his yard when he had a plumbing problem. He wasn't treating the waste.
After buying a box of one gallon zipper freezer bags at the grocery, I filled 12 or 14 of them with water, zipped them shut, and hung them around the fence using coathangers as hooks. I also put some by our patio and patio door and bbq grill.
It worked.
Of course, on the internet there are claims it's "an old wives tale".