A froggy visitor

From CSSEMediaWiki
(Difference between revisions)
Jump to: navigation, search
Line 1: Line 1:
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
+
Should a frog be able to export itself? For those that think not, the [[Visitor|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()
 
*EggyExportOperation()
 
*TadpoleyExportOperation()
 
*TadpoleyExportOperation()

Revision as of 03:00, 3 August 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
Personal tools