Skip to Content.
Sympa Menu

patterns-discussion - [patterns-discussion] Combining Command, Composite, and Visitor

patterns-discussion AT lists.cs.illinois.edu

Subject: General talk about software patterns

List archive

[patterns-discussion] Combining Command, Composite, and Visitor


Chronological Thread 
  • From: James Siddle <james.siddle AT uk.ibm.com>
  • To: patterns-discussion AT cs.uiuc.edu
  • Subject: [patterns-discussion] Combining Command, Composite, and Visitor
  • Date: Fri, 3 Aug 2007 14:14:57 +0100
  • List-archive: <http://lists.cs.uiuc.edu/pipermail/patterns-discussion>
  • List-id: General talk about software patterns <patterns-discussion.cs.uiuc.edu>


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: james.siddle AT uk.ibm.com
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









Archive powered by MHonArc 2.6.16.

Top of Page