I've been asked a theoretical design question with an eye upon the GoF patterns.:
"Given a design for a tree using a standard visitor pattern, how would your design look to allow a user to choose between om pre-order, in-order or post-order traversals?"
I'm thinkin of just letting the visitor be, but give the traversal over to an Iterator object following the Iterator Pattern.
The idea would be to implement 3 iterators that enable the desired traversal. They have an interface and the Visitor only needs to interact with this interface, giving itself as an argument to the iterator which provides traversal. The user can choose which iterator to use when giving one to the visitor.
Does this sound like an elegant solution? Any better ideas?