/visitor

Simple project representing the Visitor design pattern.

Primary LanguageJavaGNU General Public License v3.0GPL-3.0

Visitor

Code

Simple project representing the Visitor design pattern.

Definition

Visitor is a behavioral design pattern that lets you separate algorithms from the objects on which they operate.

image

In essence, the visitor allows adding new virtual functions to a family of classes, without modifying the classes. Instead, a visitor class is created that implements all of the appropriate specializations of the virtual function. The visitor takes the instance reference as input, and implements the goal through double dispatch.

image

Source: Wikipedia | Refactoring Guru