I recently ran into quite an ironic situation. After changing a small part in some code and telling my computer to start compiling, I switched to a website and ran into this:
[xkcd comic 303 by Randall Munroe]
At my company they choose to work with a tool that's notoriously slow at compiling programs. It's chosen for the ease of implementing programs, they're used to working with this language.
I often find myself hitting the compile button, and either waiting for about 30 seconds or getting distracted. After those 30 seconds, I get back to work, only to find that I made a small mistake, and have to hit compile again within two minutes.
Waiting for 30 seconds once isn't too terrible, but having to do it about 15 times an hour is tedious. Getting back to work after those 30 seconds gets harder by the day.
How can I stay productive?
Apparently the kind of mistakes I run into wasn't clear. I'm not talking about mistakes caught by the compiler. It's mostly mistakes that I only spot once the program is running, for which it needs to compile. For instance, interchanging two (poorly documented) ID's. The mistakes are hard to see from the code, but easy to notice from the behavior.
I've taken from a lot of the suggested answers, and none of them is "the right one", as they all offer different ideas and opinions. Some are great ways to speed up the compiling, but unfortunately none of those apply to me. I work on a fast system with 2 ssd's, but the bottle neck is that I'm working on Android, which has to upload via an USB. So as the compiling can't be sped up, I'll have to keep my workflow going differently.
@Coteyr's answer is great, but unfortunately this is pretty much my sole project. That does allow me to focus on this project better, but as I don't have too much other work to do aside this, I won't be able to apply this answer to myself. I hope others find it useful though.
Dennis' and Иво Недев's helped me a long way. I've started going through my code while it's compiling, and adding comments where needed. It's difficult to get started with though, as the idea "meh, anybody who reads that should know what it means". Pretending that people who read my code will be stupid did help a lot in adding proper documentation.
What I think had the biggest change is something not mentioned in this thread though, as I did not provide the specific details for an answer like it to come up. While walking though my process again, and actually timing the compiling time (turns out to be 1 minute 15), I realized that the biggest problem was that I couldn't actually do anything while it was compiling. Visual Studio has the nasty habit of locking your files... So thanks to https://stackoverflow.com/questions/3123624/visual-studio-locking-files-while-debugging I've managed to change that, and I can say, it helps a lot to be able to touch your code while it's running.
A big thank-you to everybody who replied, it just became a lot easier for me to keep up my focus for 8 hours a day.
(Please if you have any other suggestions, do feel free to add them as answers, they could be very helpful for future passers-by)