For self-defense and so many other activities, visualization and thought beforehand are absolutely critical. You have to imagine yourself in various situations and think about what you would do, and really imagine that you are there. Play it out in your mind. Think about the details, think about how you would first perceive a threat, how you would mentally prepare for that threat, how you would react if a threshold were crossed. It really is a great responsibility, and there are lots of legal considerations, but the primary consideration is that you do survive. I agree with the post that says if you can avoid the confrontation (run), you should do that. Massad Ayoob used to keep a $10 bill wrapped around a book of matches so that if punks threatened him, he could toss it to them and say look, I don't want any trouble, go and buy yourselves a beer. But at the same time, he would closely watch them for any escalation of the threat, and he would have proven his intention of a peaceful resolution. If the assailant started to move in, he would realize that this guy (or guys) probably isn't trained or accurate, and I don't have the luxury of freaking out and diving for cover while he wildly shoots. Then I am at his advantage, I am cowering and vulnerable.
No, I will be the one to dictate what happens. I will be the one who decides what to do and when. And in the worst case, I will not concentrate on the fear of a punk with a gun, instead I will concentrate on plinking a target. I can hit a soda can a long way off, and this guy is a lot bigger and closer than that. He is overconfident, and I am certain of the outcome. If it happens, I will tune out my fear and concentrate on shooting center mass. The odds are that he will miss and I will not. The odds are that I will be fast and he will be clumsy. I like the odds. I hope that I will never have to test my visualization in real life, but if necessary, I hope that I will be calm and do what I must.