Design Pattern: Visitor Pattern

Visitor pattern moves the operation or calculation part from the element/subject classes to a completely separate class. That separate class is called the visitor. As the operation/calculation is moved to the visitor class, so if we want to change the operation then we can just change the visitor class. No change in the subject classes is required in that case.

Design Pattern: Visitor Pattern in Java

Visitor pattern is used to move the operation/calculation part from a group of classes to a completely separate(Visitor) class. This article demonstrates Visitor pattern implementations in Java.