It's funny that you mention debugging computer code as an analogy, since writing computer code is also one of the most commonly used ways to check an answer to a tough probability question.
Your particular probability question is a good example of the advantage of using a computer simulation to approximate a probability rather than derive the exact probability analytically. The exact probability you seek can be derived analytically, but it is far from trivial.
An easy way to get a good estimate for the probability is to write a program that simulates the 8 hat selections. Run the program a bunch of times (>10000 loops), count the number of times that no man picks up his own hat, then divide by the number of the loops.
Furthermore, if the number of possible outcomes isn't too large, you can even use a computer simulation to compute the exact value of the probability in question. In the case of 8 hats randomly assigned to 8 men, there are only 8!=40320 possible outcomes. Each of the outcomes is equally likely, so simply have your program generate all 40320 outcomes and count how many of those outcomes have all eight hats mismatched. A modern computer can do this in no time at all. My program reports the probability at 14833/40320.
Of course, if you're going to use a computer program to check/find an answer to a probability question, you must be careful to write your code correctly.