Three Stages of Defense
I have found it very useful to divide the defense of a hand into three stages: The opening, the middle game, and the end game. These are characterized by different amounts of knowledge, which can lead to very different strategies for deciding on the best defense.
The Opening and Principles of Play
I have seen problems where the defender places every card in the hand and then finds the brilliant opening lead. But it's usually a fantasy. At the start of play, you are just following principles of defense. These include second hand low, third hand high, cover an honor with an honor, lead to weakness in dummy, lead top of a sequence, etc. When you start the defense of a hand, you can usually do no more than follow these principles.
Some people never do anything more than follow principles. They are not great defenders, but you can be a pretty good defender just following principles.
As the hand progresses, you gain more and more knowledge about the distribution and location of the relevant high cards. At some point, you essentially know the whole hand. Then it is simply a matter of choosing the most effective play. I call this the end game.
Usually, the basic principles will lead you to the right action even in the end game. But the exciting thing about the end game is that sometimes you do the opposite of the principles. For example, holding Q10 doubleton of hearts sitting behind the AK9xxxx of hearts in dummy, I led the queen of hearts. I could place everything in the hand well enough to know that declarer had a squeeze for the rest of the tricks if I led anything but a heart.
One goal of good defense is to get to the end game as soon as possible. This means drawing every possible inference and active signalling by the defenders. But you never get to the end game if you don't count out a hand. I have a tutorial on counting here.
Given perfect knowledge of all of the remaining cards, you still might not be able to work out the best defense. With six cards left, there can be very difficult double dummy problems. Usually, you just grind out the possibilities. For example, you calculate what will happen if you lead a club, then you calculate what will happen if you lead a diamond. The correct strategy is usually possible to work out, though I have seen difficult endgames. (e.g., here).
Sometimes, you don't know everything that is relevant. For example, you might not know the location of a 10 when that 10 has become a key card. But it is still the end game if you can reduce the hand to a few possibilities and then select the best alternative to cater for the existing possibilities.
The Middle Game
The Middle game occurs in the middle of the hand. First, you are drawing inferences from declarer's strategy (and partner's). Second, you are starting to map out your own strategy -- where are your tricks coming from?
For example, dummy had AQx in a suit and I was sitting behind the dummy with Jxxx. I was on lead around trick three and decided that we needed to get a trick in this suit before declarer set up discards in another suit, and furthermore that we might have time. So I led the suit, hoping in fact that partner would have the king.
A middle game problem