users
[Top] [All Lists]

RE: [cinjug-users] Command pattern?

To: <users@xxxxxxxxxx>
Subject: RE: [cinjug-users] Command pattern?
From: "Taylor, William J." <Bill.Taylor@xxxxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 8 Jul 2005 13:37:06 -0500
Delivered-to: mailing list users@cinjug.org
Mailing-list: contact users-help@cinjug.org; run by ezmlm
Thread-index: AcWD62Xl+Pte1z19QA2shgYl3x1aaQAAEn7AAAAHzFA=
Thread-topic: [cinjug-users] Command pattern?

I was going to say the same thing…

 

I think I found what I needed by googling java commandProcessor.

 

Thanks!

 

bt

 


From: James Carman [mailto:james@xxxxxxxxxxxxxxxxxxxx]
Sent: Friday, July 08, 2005 2:35 PM
To: 'Amol Deshmukh'; Taylor, William J.; users@xxxxxxxxxx
Subject: RE: [cinjug-users] Command pattern?

 

Hey, that sounds familiar.

 


From: Amol Deshmukh [mailto:adeshmukh@xxxxxxxxxxxxxx]
Sent: Friday, July 08, 2005 2:28 PM
To: 'Taylor, William J.'; users@xxxxxxxxxx
Subject: RE: [cinjug-users] Command pattern?

 

You could have a HashMap of CommandName mapped to CommandProcessor(s).

The CommandProcessor would be an implementation of the Command Pattern.

The advantage being that you could register handlers for new commands easily without

having to add if-else conditionals.

 

~ amol

 

-----Original Message-----
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>