Reflective Visitor Pattern.

Yun Mai, Michel de Champlain · 2001

The Visitor pattern wraps associated operations that are performed on the elements of an object structure into a separate object. It allows the software designer to define new kinds of operations over the object structure without changing the classes of this structure. But a well-known drawback of this standard Visitor structure is that extending the object structure is hard. This paper presents the design and implementation of a flexible Visitor pattern based on the reflection technique, we call it the Reflective Visitor pattern. The reflection technique enables the Visitor to perform the run-time dispatch action on itself. The separation of the run-time dispatch action from the object structure makes any extension to the object structure become easy. It also removes the cyclic dependencies between the Visitor and the object structure, so the reusability and extensibility of the system are improved. Intent Define a new operation over the object structure without changing the classes of the elements on which it operates, while in the meantime, allow the element classes in the object structure to be extended constantly without changing the existing system.

Read the paper · More papers on PaperTik