users
[Top] [All Lists]

RE: [cinjug-users] Command pattern?

To: "'Taylor, William J.'" <Bill.Taylor@xxxxxxxxxxxxxxxxxxxxxxxx>, <users@xxxxxxxxxx>
Subject: RE: [cinjug-users] Command pattern?
From: "James Carman" <james@xxxxxxxxxxxxxxxxxxxx>
Date: Fri, 8 Jul 2005 14:28:18 -0400
Delivered-to: mailing list users@cinjug.org
In-reply-to: <83FF13B05A04FD40ABD40D3A9FFE135568BC85@s000pex03.HaverstickConsulting.com>
Mailing-list: contact users-help@cinjug.org; run by ezmlm
Thread-index: AcWD6fN0hBarpgxmT3e5XUSTXTWxjwAAKbPA

Why don’t you try registering command processors in some sort of lookup table (a Map comes to mind)?  You could use the command name (upper or lower case what the user types so that it matches always) and some sort of CommandProcessor object as the value.  Then, on the server, it’s just a matter of looking up the command processor object in the map and delegating to it.

 


From: Taylor, William J. [mailto:Bill.Taylor@xxxxxxxxxxxxxxxxxxxxxxxx]
Sent: Friday, July 08, 2005 2:22 PM
To: users@xxxxxxxxxx
Subject: [cinjug-users] Command pattern?

 

-->

I’m working on interfacing with a web service that performs search capabilities for our client.

 

The search functionality is very interactive where a user types in a command and waits for a return. There is a whole list of commands that they could enter such as search, remove duplicates, sort, etc. (This would work similar to a UNIX/DOS prompt)

 

My task is to put a front end web interface and pass the commands to the web service and display the results.

I have a working prototype but I’m not happy with the way I evaluate each command.

 

At the moment I’m simply doing this:

 

if(“search”.equalsIgnoreCase(command))

{

            //do something here

}

 

If(“dup”.equalsIgnoreCase(command))

{

            //do something here

}

 

//etc – for the next 20 commands.

 

I have looked at the command pattern but from I’ve read so far this doesn’t seem like a great fit.

 

Is there a better way to encapsulate each “command” so they can be evaluated and passed on to the correct service?

 

BTW, this is a pure Struts app. (no Spring %-) )

 

--

Bill Taylor

 

<Prev in Thread] Current Thread [Next in Thread>
  • Command pattern?, Taylor, William J.
    • RE: [cinjug-users] Command pattern?, James Carman <=