O'Reilly logo

Visual Basic Design Patterns: VB 6.0 and VB.NET by James W. Cooper

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 32. The Visitor Pattern

The Visitor pattern turns the tables on our object-oriented model and creates an external class to act on data in other classes. This is useful when you have a polymorphic operation that cannot reside in the class hierarchy for some reason—for example, because the operation wasn't considered when the hierarchy was designed or it would clutter the interface of the classes unnecessarily. The Visitor pattern is easier to explain using VB7, since polymorphism and inheritance make the code rather simpler. We'll discuss how to implement the Visitor in VB6 at the end of this chapter.

Motivation

While at first it may seem “unclean” to put operations inside one class that should be in another, there are good reasons for doing ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required