Lecture overview -- Keyboard shortcut: 'u'  Previous page: Natural object-oriented IntSequence traversals -- Keyboard shortcut: 'p'  Next page: A Visitor example: IntSequence -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Textbook -- Keyboard shortcut: 'v'  Help page about these notes  Alphabetic index  Course home  Page 35 : 37
Object-oriented Programming in C#
Abstract classes, Interfaces, and Patterns
Towards a Visitor solution

The transition from natural object-oriented traversals to Visitor

  • Steps:

    • A Visitor interface and three concrete Visitor classes are defined

    • The Intsequence classes are refactored - the traversal methods are moved to the visitor classes

    • Accept methods are defined in the IntSequence classes. Accept takes a Visitor as parameter

    • Accept passes this to the visitor, which in turn may activate Accept on components

Try the accompanying SVG animation