Hi, I was wondering if anyone has examples of successful combinations of the Command, Composite, and Visitor patterns in Java. I'm attempting to introduce Visitor into a Composite & Command implementation (as described in Chapter 6 of POSA5), but have run into a problem.
In my current design, a "Command" interface is implemented by concrete command classes, and a CompositeCommand class implements Command in order to aggregates other commands. This means I can hierarchically compose commands. What I'm struggling to know is how to introduce a "Visitable" interface onto the Command classes, without tying the Command interface to the Visitor interface. I've narrowed my choices to three options, so any guidance on which one to go for would be appreciated :-) The options are: 1) Add 'accept' onto the Command interface -> means that Command interface will indirectly have knowledge of concrete commands, by knowing about the Visitor interface. 2) Have a separate Visitable interface -> means that my CompositeCommand class will have to use runtime type information when passing on accept calls to aggregated commands, which may not implement Visitable 3) Introduce a VisitableCommand interface, and change concrete command classes to implement it -> this option just isn't feasible in my current configuration partly because it would involve changing code which it just isn't possible to change Any thoughts appreciated, Thanks, Jim James Siddle IBM WebSphere ESB Foundation Technologies telephone: +44 1962 81 6055 email: [EMAIL PROTECTED] personal webpage: www.jamessiddle.net Unless stated otherwise above: IBM United Kingdom Limited - Registered in England and Wales with number 741598. Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU
_______________________________________________ patterns-discussion mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/patterns-discussion
