This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
In ActionClass we can use only one action i.e execute(), but in DispatchAction we can use multiple actions.My question is , we can use multiple actions in Action class if(action.equals("add") ,if(action.equals("update"). Then when to use Action and DispatchAction which is frequently in webapplications.
This is the struts framework. Not sure which one is used more than the other. I have worked on applications that use both. I guess it depends on if you have several action paths, and the functionaluty of each path is similar, then the dispath action may come in handy. Especially if the same form bean is being used for all the different paths/actions.
Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Doing conditional logic in an execute() method is just one way (a messy one) to implement DispatchActon. I can't think of any particular reason to do the work manually when a mechanism already exists--except if the decision-making process is more difficult than a simple string (for example, which method might depend on a combination of factors).