Random Code Generator

A few days ago I was working on a bug, I prepared the fix tested it then I found a nicer way of doing something and changed the fix again then tested it but I realized I forgot a “not” (! In c#) which spoil the code terribly. One character. So as an engineer I started thinking about this, why it happened and is there a way to prevent this or if not, is there a way to automatically fix this. Automatically fix this , Automatically fix this , Automatically fix this , who can fix it automatically? Can a software fix another software? It might not be feasible right now for a software to code something but at least can it randomly attack a piece of code change stuff, dump if’s , loops , manipulate variables etc .Or if we want to start scratch we will give function signature, set of correct inputs and out puts and do not care what is inside the function . Can a software randomly dump lines into this function ,build it , run it and satisfy the input/output requirements ? If you say a it is impossible how about we have a dictionary of ready lines and software can mix and match lines from the dictionary. I am sure this will be a dream machine for lazy developers : ) . But don’t underestimate lazy people, they are the reasons for many inventions ; ). Anyway this much of daydreaming is enough for today, I need to go back to my longhorn RC bugs which will not be fixed automatically for sure.