In my last job interview I got a (rather vague) question about traversing a tree and operating on the tree nodes. I think I’ve a lot of experience in programming but I couldn’t figure out the answer on my own. The answer the guy wanted to hear was: visitor pattern.
I had never heard of it before. So, in preparation for my next job interview, I thought I take a look at it.
While trying to figure it out, I stumbled over this quote:
The Visitor pattern is possibly the most complicated design pattern you will face. (Source)
I totally agree. (And this is probably why I’ve never heard or used it before.)
But since I’m not a quitter I went on and tamed it. So, in this article I’m going to shed some light on this mysterious design pattern.