You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jordan Thomas <jo...@ipa.fraunhofer.de> on 2002/12/11 19:05:36 UTC

Struts design: All actions in one ActionClass

Hi,

What is the best way to design my application? Is it better to

a) Put all my actions for a particluar area (i.e. creating, editing and
deleting user accounts) in one Action class

or

b) Use a seperate action class for every action in my application

or

c) Put all of the actions for a particular workflow in a single Action
class.

I am looking to have an application that is easy to maintain and flexible.
Suggestions/Advice would be most appreciated.

thanks

Jordan


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Struts design: All actions in one ActionClass

Posted by Patrice <pp...@nerim.net>.
For me, it's easy to maintain seperate actions.
If you want to group different actions in one Action class, you might use a
DispatchAction with a method for each process.

Hope it helps

Patrice

----- Original Message -----
From: "Jordan Thomas" <jo...@ipa.fraunhofer.de>
To: "Struts-User" <st...@jakarta.apache.org>
Sent: Wednesday, December 11, 2002 7:05 PM
Subject: Struts design: All actions in one ActionClass


> Hi,
>
> What is the best way to design my application? Is it better to
>
> a) Put all my actions for a particluar area (i.e. creating, editing and
> deleting user accounts) in one Action class
>
> or
>
> b) Use a seperate action class for every action in my application
>
> or
>
> c) Put all of the actions for a particular workflow in a single Action
> class.
>
> I am looking to have an application that is easy to maintain and flexible.
> Suggestions/Advice would be most appreciated.
>
> thanks
>
> Jordan
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Struts design: All actions in one ActionClass

Posted by Rick Reumann <ma...@reumann.net>.

On Wednesday, December 11, 2002, 1:05:36 PM, Jordan wrote:

JT> a) Put all my actions for a particluar area (i.e. creating, editing and
JT> deleting user accounts) in one Action class

    I guess I am in the minority here but lately I've been building
    one big DispatchAction class that acts as my controller. To me it
    seems very easy to maintain as each method name in the DispatchAction
    corresponds to something easy to understand:

    ie:
    updateEmployee(... )
    insertEmpployee(... )
    getEmployees( ... )

    Even though this class can become very large it's very simple to
    work with since

    a) any decent IDE will show you the methods at a glance in this
    DispatchAction so it's just as easy to find what you need in the
    class as it is looking in a directory structure.

    b) There isn't any business logic in each of the action methods.
    Each action basically just handles passing the form off to a
    service object. In my action methods I do stuff like put certain
    things into request or session scope, create ActionMessages, and
    figure out what ActionForward to set up. That's about it.

    The only real drawback that I can see to this approach of one
    DispatchAction is it prevents other team members from working on
    some tasks if the one DispatchAction is getting all mucked up.
    Doesn't seem like a big drawback to me, though since it should
    only take a minute or two to add a new method to the
    DispatchAction.

    The other drawback I find is sometimes if you aren't careful the
    struts-config file can get confusing, but this is probably do more
    to my laziness. I say this because, when I can, I try to make one
    defined Action in the config take several dispatch values. For
    example I might have a mapping like:

<!-- Dispatch values: enterProject,insertProject,updateProject -->
<action path="/projects"
    type="com.outback.taskmanager.actions.TaskManagerAction"
    name="projectForm"
    scope="request"
    validate="true"
    parameter="dispatch">
    <forward
            name="enterProject"
            path="/WEB-INF/jsp/projectForm.jsp"/>
    <forward
            name="insert-success"
            path="/WEB-INF/jsp/confirmation.jsp"/>
    <forward
            name="update-success"
            path="/WEB-INF/jsp/confirmation.jsp"/>
</action>

Notice that if I didn't add the comments above the <action > it could
later get confusing what action methods in your DispatchAction correspond to this
action mapping.

I'd be curious to know if anyone else does something similar or if I'm
way off base here. To me it seems like a clean way to do things.


    Just me 2cents.
    If the approach above is bad/wrong, please let me know.
    
    Thanks,
    
-- 

Rick
mailto:maillist@reumann.net


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>