I do think is valid to show code produced just-in-time, but I don't it's okay to observe the candidate, for the reasons already pointed out.
If you must ask for code, give the candidate a computer and leave the room, or have the candidate leave the room with a computer and leave him to it.
You should be at least partially trying to emulate real working conditions. Otherwise it's just torture.
I do think is valid to show code produced just-in-time, but I don't it's okay to observe the candidate, for the reasons already pointed out.
If you must ask for code, give the candidate a computer and leave the room, or have the candidate leave the room with a computer and leave him to it.
You should be at least partially trying to emulate real working conditions. Otherwise it's just torture.