ENGLISH
REFERENCE

visitor pattern

compound.
C2 Proficiency Programming
Definition

compound. a way of writing computer code that lets you add new features to a group of objects without changing the objects themselves. It helps keep different parts of a program separate and clean.

compound. a behavioural design pattern that separates an algorithm from the object structure on which it operates, allowing new operations to be defined without modifying the classes of the elements being visited.


SIMPLE

The developer used the visitor pattern to add export features to the document.

CONTEXTUAL

By implementing the visitor pattern, the team could add new reporting tools to the existing database structure without risking bugs in the core data classes.

COMPLEX

The visitor pattern is particularly effective in compiler design, where it allows various analysis and optimization passes to traverse an abstract syntax tree without cluttering the node classes with logic.

Origin

A compound term formed from the noun visitor and the technical sense of pattern. It was formalised by Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides in the 1994 publication Design Patterns: Elements of Reusable Object-Oriented Software.

Etymology adapted from Wiktionary, available under CC BY-SA 4.0.

Usage

Commonly used in object-oriented programming; typically involves an 'accept' method on the element and a 'visit' method on the visitor.

Related words

Last updated July 22, 2026