A froggy visitor
From CSSEMediaWiki
Revision as of 09:15, 7 October 2008 by Dominic Winkler (Talk | contribs)
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.