Visitor Pattern
You will go over the visitor pattern in detail with the help of a coding example in this lesson.
We'll cover the following
What is the visitor pattern?
The visitor pattern allows the definition of new operations to the collection of objects without changing the structure of the objects themselves. This allows us to separate the class from the logic it implements.
The extra operations can be encapsulated in a visitor object. The objects can have a visit method that accepts the visitor object. The visitor can then make the required changes and perform the operations on the object that received it. This allows the developers to make future extensions, extend the libraries/frameworks, etc.
Level up your interview prep. Join Educative to access 70+ hands-on prep courses.