A froggy visitor

From CSSEMediaWiki
Revision as of 06:33, 2 August 2008 by Tureiti Keith (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Can a frog 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