Hi 

I've read alot about Ted's thoughts on using one action for serveral different action 
mappings and using mapping.getParameter to decide which code to execute.  He mentions 
it's uselful for grouping themed operations (eg. operations on a shoppingCart, 
customer, etc).

I like the idea in theory since it does mean fewer action classes need to be 
instantiated and it groups related operations in one class.  

On the other hand,

It results in the same problems prior to struts where you'd have a 
ShoppingCartServlet, CustomerServlet etc and each servlet would be given an "action" 
parameter.  Eg. In the servlet you'd have a big if else block to choose what code to 
execute with lots of methods for each posible action for ShoppingCarts, or Customers, 
etc.  All this code makes it harder to maintain and more people lining up to modify 
that class.  In a way it takes away the cool thing about Struts using the Command 
pattern allowing for a "AddToShoppingCartAction", "DeleteShoppingCartAction", etc into 
a "ShoppingCartManagementAction".

Having separate action classes does take up more memory sine they exist for the life 
of the web app but their smaller, less contention to modify.  Code reuse b/w actions 
could still be achieived via subclassing.

Yet I still like Ted's idea :)

DispatchAction is a hyrbrid of the two usages of Actions but it makes validation for 
different types of actions a lot tricker---eg. same strut mapping different parameter 
meaning you can only have one form bean for all actions and your validate needs to do 
a big if else check on parameter to see which validition to execute.

Does anybody have any ideas on which design they prefer....or are there other ways as 
well to design web apps with struts.

Thanks

Francis



---------------------------------
Do You Yahoo!?
Yahoo! Finance - Get real-time stock quotes

Reply via email to