A froggy visitor

From CSSEMediaWiki
(Difference between revisions)
Jump to: navigation, search
Line 10: Line 10:
  
 
[[image:AFroggyVisitorCommunication.JPG|frame|centre|'''Figure 2: A [[UML 2.1]] [[Communication diagram|communication diagram]] describing an application of the Visitor pattern interactions to the [[Frogs design]]''']]
 
[[image:AFroggyVisitorCommunication.JPG|frame|centre|'''Figure 2: A [[UML 2.1]] [[Communication diagram|communication diagram]] describing an application of the Visitor pattern interactions to the [[Frogs design]]''']]
 +
 +
 +
==See also==
 +
*[[Visitor]]

Revision as of 09:15, 7 October 2008

Should a frog be able to export itself? For those that think not, the Visitor pattern may provide a solution. Figure 1 presents an application of the Visitor pattern structure to the Frogs design, the interactions are described in Fig. 2. Here, the Exporter class and its child play the role of the visitor. The Frog class accepts visits from an Exporter object, then passes itself to the Exporter. The Exporter then performs operations using the Frog object. These operations are captured in the methods

  • EggyExportOperation()
  • TadpoleyExportOperation()
  • AdultFroggyOperation()

Although, an Exporter is more likely to be interested in the attributes of a Frog object.


Figure 1: A UML 2.1 class diagram describing an application of the Visitor structure to the Frogs design


Figure 2: A UML 2.1 communication diagram describing an application of the Visitor pattern interactions to the Frogs design


See also

Personal tools