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.
I was just wondering if someone could give me their views on the 'best practice' for struts2 when it comes to Actions.
I have been creating an app that currently uses a UserAction class; this contains all my methods for login, loginConfirm, register, registerConfirm, userProfile etc etc etc.
I was just wondering if it is considered 'right' to group all User actions in one class, or is I should be doing something like:-
UserLoginAction, UserregisterAction, UserProfileAction. Or does it really not matter.
Just really wondering if I'm heading down the right road, or straying away from Struts'best practice'.
Keep in mind that the Struts Framework Action class is a component of a Struts-based Controller (in MVC terms.) When programmers use Struts while building their applications, they add behavior to a Controller by creating customized Action classes and then configuring them with the other parts of the Controller that come with the Framework.
To summarize, custom Action classes, the pre-written Struts classes and an instance of struts-config.xml together are your Controller. You should not code customized business logic in Action classes, i.e. the Controller. This logic belongs in Model classes, not Controller classes.
A Presentation-tier Business Delegate is typically the mediator between a Controller and Model.