The answer to this question depends largely on the species of fly. We generally notice flies at two points in their development: when they are adults flying around busily preoccupied with mating and egg laying and when they are maggots mining between leaf surfaces, tunneling into roots, and feeding on developing fruit in our gardens. Flies, in fact have four stages of development: egg, larva, pupa, and adult. In the language of entomologists this is called a complete metamorphosis. Most species of fly spend the winter buried 1 to 6 inches beneath the soil in their third or pupal stage of development. Some species, however can overwinter as adults or even as maggots (the larval stage of development).
The fly life cycle begins with the adult laying eggs on a host, usually on leaves or developing fruit, and occasionally in the soil around the base of the plant (depending again on the species of fly). The eggs then develop into maggots, the feeding stage for the fly. Maggots resemble plump worms and may be legged or legless; hairy, spiny, or smooth; white or yellow, brown or green; with chewing mouthparts for munching on foliage and fruit. Although they may increase in size during the larval stage, they change very little in appearance.
After feeding voraciously in your garden, the maggot enters the third stage of development - the pupal stage. During pupation the insect stops feeding or even moving, often forming a hard case around its body (a cocoon or pupal case) for protection. Within this casing the insect profoundly changes from the worm-like maggot to the winged, legged, antennaed adult fly. The adult fly does not feed but spends its time in procreation followed quickly by death. This final stage is the shortest and most active stage in the life of the fly.
For gardeners the easiest and most effective time to control the fly population is just after egg laying or as the maggots emerge, which for single generation species may be in early or late spring, and for multiple generation species will occur throughout the growing season. The number of generations produced in any given year will depend on the species of fly and environmental conditions such as the availability of food, the presence of predators, and the control measures taken by the gardener.