What is the relation between mixing the dough and the final result? I often see recipes that just ask to mix the ingredients until you get an homogeneous mix. Others ask to mix the ingredients to exhaustion.

What happens to the though while I mix it? Does that really make a difference? What should I expect, as final result (after cooking) from a dough that was only mixed to the point it gets homogeneous from one that I mix hard for a long time?

I am mostly talking about bread and cake dough. But I was wondering if there is a general rule so I know what to expect.
Okay, so I presume that we're talking about recipes containing wheat flour and you're putting together a dough (or batter) for a bake or maybe even a pasta.

In general, mixing wheat flour with water results in the production of gluten.  Gluten is pretty tough stuff; it's essentially what gives a finished wheat product its chew and contributes greatly to its overall structure.  The more you mix (or knead), the tougher the resulting dough and finished product.