Oh Einstellung!

In your journey as a software developer, have you ever encountered a difficult problem that you couldn’t solve? And then, in a flash of insight, a potential solution occurs to you! You joyfully code it up and behold, it works!

There’s a problem, though. The performance is abysmal. Or you had to violate good practice to get your code to work, like working with global variables or some bothersome dependency. Your code smells like all the herring in the world laid end-to-end across the Sahara Desert.

You know something is wrong, so you try to think of other solutions. Nothing suggests itself. You just accept that, flawed as it is, this is the only possible solution.

Then a more senior programmer reviews your code and not only points out all your faults, but suggests a simpler, more performant solution that was right in front of you the whole time. The better code is obvious in hindsight, but when you were writing the code, you didn’t see any of that.

You, my friend, have fallen victim to a cognitive trap that psychologists have dubbed the “Einstellung effect”.

The Einstellung effect, from the German word for “mindset, is a cognitive phenomenon that occurs when you get stuck on a solution to a problem and you are incapable of considering alternatives. According to Barbara Oakley in A Mind for Numbers, “an idea you already have in mind, or your simple initial thought, prevents a better idea or solution from being found.”

As a novice and junior programmer, I fell victim to the Einstellung effect on several occasions. However, cognitive research indicates that experts fall into this trap just as often and may be even be more prone to Einstellung than novices.

There is None So Blind and Those Who Will Not See

Psychologists do not know the precise cause of the Einstellung effect, but their studies seem to indicate that once we glom onto a familiar solution, a sort of blindness sets in. In experiments with chess players of all skill levels, from grandmasters down to amateurs, a majority of the players identified a familiar “checkmate in five moves” scenario while totally missing a “checkmate in three moves” on the same board. The psychologists tracked the eye movements of the players and discovered that once the players identified the 5-move scenario, THEIR EYES NEVER MOVED FROM THOSE SQUARES, despite their protestations that they were scanning the board for other solutions.

In effect, the players, once they spotted their familiar solution, were blind! They literally could not see any alternatives. I’ve experienced a similar kind of blindness when looking for something in the garage that I thought was in a red container when, in fact it was in a white one. We see what we are looking for. I will even pick up the white container to see if the red container is behind it.

In the chess experiments, and others, such as the famous water jugs problem, the spell was broken for many people (over half!) if the cognitive scientist running the experiment gave them a hint, such as “Don’t be blind!” This seems to indicate there are ways to avoid or mitigate the Einstellung effect.

Avoiding the Trap

How does one avoid the Einstellung effect? There is no sure-fire method but here are some suggestions.

  1. Beware of solutions you have seen before. If a familiar context presents itself, we might allow ourselves to leap to an answer without considering the entire story. There might be some detail that is different that opens the door for a different, better solution.Or even just a correct one. Consider a doctor that listens to the patient’s symptoms and gives what seems like an obvious diagnosis, only to discover later that the same symptoms can have a different cause. Medical dramas are built on this situation—think House (“It’s always lupus”).
  2. Take a break. If you suspect you may be missing a better solution, give your mind a rest and either focus on something else or on nothing at all. This sort of diffuse thinking often results in new and better alternatives and helps you approach the problem with a fresh perspective.
  3. If you can, adopt a beginner’s mindset. Novices are sometimes able to see solutions that experts miss precisely because they have not seen this problem before. This is easier said than done, but if you can set aside your expert mindset, you may hit on a better solution. Better yet, show it to a novice and have them consider the problem.
  4. Consciously consider the Einstellung effect. Just being aware of this trap may help you avoid it.
  5. Work the problem through with a colleague. This is particularly effective in the software development arena. In general, we adopt better solutions in collaboration than in isolation, so this may be the most effective way to avoid the Einstellung effect.

The insidious thing about the Einstellung effect is that it affects both novices and experts. More training will not help you avoid the trap. We can, however, lessen the probability that we will fall into the trap.

So the next time your heart leaps for joy because you finally found a solution to a thorny problem, take a minute to sniff your code. If you get a whiff of herring, you might want to take a fresh look at the code!