This is the Visitor object extending its hand saying "please accept me polymorphically." Then the visited object responds by invoking the proper visitTypeA method of the visitor, and passing itself as a parameter back to the visitor. This is the visited object extending its hand back to the visitor, shaking its hand, and saying "Yes, I polymorphically accept you; Now you may polymorphically operate upon me."Most confusing pattern ever... I'm not sure I'm ready to polymorphically operate upon it yet. Gotta love that last anthropomorphically self-descriptive quote, though!
This chap builds a nice real-world-outside-coding analogy of the pattern; it seems much easier to grasp them via non-computing analogies (although that taxi company Visitor metaphor didn't help me at all), at least for a newcomer to patterns like myself.
No comments:
Post a Comment