Collection of references and notes on Java and J2EE

Wednesday, February 22, 2006

Best practices for Struts development - old

A old article on IBM developerworks, Best practices for Struts development, but these points are good to remember. Good OOP practices too.

Summary:
1. Instead of putting all the attributes in one single ActionForm, split it across multiple ActionForms.
2. Instead of directly extending org.apache.struts.action.Action, create an Action class (IntermediateAction) by extending org.apache.struts.action.Action to handle common things in your application.
3. If session data is maintained as a single object and/or every page manipulates or uses session data. Use an abstract class by extending ActionForm and declare abstract methods (e.g. toSession(SessionData sessionData) and void fromSession SessionData sessionData)) for getting and setting SessionData. Make your ActionForm classes extend this class and implement abstract methods.
4. Handle common tasks related to exceptions in a abstract Action class. Let all Action class extend this class, and use the common exception handling class of the abstract base class.

0 comments: