In college, I once dreamed I was in a program I was having problems with, stepping to each line and doing what it told me. I do not have any other vivid code dream memories since that one. Maybe the subsequent electroshock helped. 8-)A guy I worked with at my first job topped that. We had this godawful C program that was driven from a signal handler. Basically they were using signals and pipes as IPC; Process One would write a message and signal Evil Process Number Two to wake up and get its messages. Evil Process Number Two did eveything asynchronously from the signal handler. If you've ever lived the horrors of doing that in code that's not fully reentrant, you should be able to sympathize. This guy dreamed that he was being chased by the signals, which were striking at his feet like bolts of lightning. No lie. He left not long afterwards and went to law school.
The interesting trivia associated with that Evil Signal Handling program is that a person whose name we all know wrote the original code. Many now look to him as a guru. I guess he had to learn somewhere. I will not incriminate him by giving his name.
My big problem now is code daydreaming. It's a good way to pass the time when mowing the lawn, but when I zone out with the wife and kids present it's not so great. I just enjoy working problms over in my head like that, but it does tend to annoy those around me.