-
Notifications
You must be signed in to change notification settings - Fork 2
99. Visitor Pattern
Ercan Polat edited this page Jan 19, 2019
·
1 revision
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.
Use the Visitor pattern when…
- You have a class hierarchy that is effectively sealed.
- There are many distinct operations to perform on it.
- The operations are orthogonal to the core purpose of the types in the hierarchy.
- You need the flexibility to define new operations over time.
This pattern is useful when public APIs need to support plug-in operations. Clients can then perform their intended operations on a class (with the visiting class) without modifying the source.