The Double Dispatch pattern is a generalization of most Visitor patterns. It lets the dispatcher request different operations on each class of element without modifying the existing classes.
Profile download (Rational Rose model)
context Dispatcher inv: not self.isAbstract context Element inv: self.treeTop implies (self.isAbstract and self.dEE->size() = 1) inv: self.isAbstract implies (self.specialization->size() > 0 and self.specialization->forAll (c | c.child.oclIsKindOf (Element))) inv: not self.treeTop implies (self.dEE->size() = 0) context AcceptOp inv: self.parameter->exists (p | p.kind <> ParameterDirectionKind::out and p.kind <> ParameterDirectionKind::return and p.type.oclIsKindOf(Element) and p.type.oclAsType(Element).treeTop) context VisitOp inv: self.parameter->exists (p | p.kind <> ParameterDirectionKind::out and p.kind <> ParameterDirectionKind::return and p.type.oclIsKindOf (Dispatcher)) context aDispatcherElement inv: self.dEE.isNavigable and self.dED.isNavigable
The association should be between MazeElement and MazeVisitor. Then again, in the DD pattern there should be no Dispatcher class hierarchy, so the abstract MazeElement class should not be present and its accept() operation should be moved down into the Door class.