$> git checkout visitor
Intent
Represent an operation to be performed on the elements of an object structure. Visitor lets you define a new operation without changing the classes of the elements on which it operates.1
Applications
This is probably one of the most complicated GoF patterns I’ve seen. The first time I stared at the UML diagram after a while I said, “hmm, wat 2?” At its basic form, this pattern is all about extracting methods from semi-related or unrelated classes. When you do this, you no longer have to change or revisit (pun intended) the code. After reading more about this pattern I ...