Flies come from eggs. In the common housefly, these eggs are often laid in manure, wet compost, carrion, feces or other damp organic matter. After a few hours, they hatch into maggots.
When the maggot hatches, it feeds for about five days before crawling to a dry place to pupate. It remains a pupa for another five days, then hatches into an adult fly. Flesh fly eggs hatch within the mother's body and are born as maggots. The larvae of some types of fly, such as the black soldier fly, are so reliable that forensic entomologists use them to determine the time of death for corpses.