The development of a simple fertilized egg cell to an adult fly over the course of a few weeks is an amazing transformation. A lot of things have to happen: the body form must be laid out (head/tail, back/belly), different tissues must be built, and organs must be grown. The adult fly is composed of a lot of very different parts made of different cells  yet every cell carries the same genetic instructions. So how does it "know" what to do? What genes factor into this transformation?

Certain genes control where and when other genes are expressed
Not all genes code for "building material" proteins (such as keratin which makes up part of your skin, or rhodopsin which makes eyes sensitive to light). Regulatory genes control when and where other genes get turned on. For example, these sorts of genes tell the cells of the fly when and where to start building wings. This occurs during the larval stage on the second and third segments of the thorax. Regulatory genes can start a "chain reaction" of effects, turning on and off other genes, whose products affect other genes, whose products in their turn affect other genes, and so on. A single regulatory gene can thus control the construction of a body part as complex as a leg or eye.

Master control genes regulate other genes, which in turn, regulate other genes.

In the 1980s, researchers discovered a series of genes called Hox genes that set the identity of segments of insect bodies from head to tail. Hox genes are examples of these "general purpose" control genes and are important elements in building complicated organisms like flies. They help lay out the basic body forms of many animals, setting up the head-to-tail organization. You can think of them as directing instructions as an embryo develops: "Put the head here! Legs go over there!"

Mutations to Hox genes can put an entire leg where an antenna should sprout out (right) and produce other equally grotesque transformations. Small changes in such powerful regulatory genes, or changes in the genes turned on by them, could represent a major source of evolutionary change.

Interestingly, many different organisms, including insects, humans, and mice, inherited homologous Hox genes from our common ancestor. In us, these genes control the development of our head-to-tail anatomy as embryos. Similar genes controlling the eyes of insects and our own eyes have also been discovered. (Our version of the gene can be inserted in a fly and still trigger the building of an insect eye!) It now appears that some 600 million years ago, a common ancestor of most animals on Earth today acquired a "genetic toolkit" of these body-building genes. Although the structures that these genes build have changed, the genes have been conserved.

Different cells have different genes expressed
For example, eye cells turn on the genes that make proteins necessary for vision — but the cells lining the digestive tract don't turn on these genes. Instead, they turn on genes that create digestive enzymes.

Different segments of the developing fly embryo express different genes.

Chemical signals also influence the fate of cells
Chemical signals from the environment and from other cells can affect which genes are turned on in a particular cell. For example, in the developing vertebrate eye, chemical signals from the retina probably cause adjacent cells to become lens cells instead of some other type of cells. Here we see a diagram of the optic cup, of which the retina is part, developing normally. As a result, it sends signals to nearby cells, causing them to form a lens from the epithelium. The pictures below illustrate what happens to lens development if the optic cup is removed, transplanted, or replaced by other tissue.