Context: |
Some polymorphic processing is configurable and, therefore, may not be part of the processed type family (e.g. formatting, user interface). Processing depends as much on the processor type as on the processed type and must be done by the processor. |
||||||||
Challenge: |
To add the virtual function hierarchy to a class hierarchy without opening it. |
||||||||
Skill: |
|||||||||
Participants: |
|
||||||||
Signature: |
Visitor processes Subject by requesting Subject to "accept" it (the Visitor). Concrete Subject, requests Visitor to "visit" it (the Concrete Subject). |
||||||||
Used patterns and idioms: |
Double-Dispatch idiom. |
||||||||
Used by: |
Document/View architectures, dynamically configurable reporting/rendering systems. |
||||||||
Variations: |
|
||||||||
Known issues: |
|
||||||||
Scope: |
Languages that do not support multi-methods (most commercial OO languages). The Visitor is really a multi-method over Concrete Visitor and Concrete Subject types). Aspect oriented programming attacks the problem by from another direction. |