Graham Lounder wrote:

Hey all,

After reading the "[Poll] action mappings" thread, I now have a couple of
design questions. I've got a lot of actions right now and I'd like to
group related functionality into one action. I'm thinking of extending the
DispatchAction and creating functions to
search/view/create/update/delete/load my objects.


I would strongly advise against this. Keeping each action simple is the way to go.

2 1/2 years ago I had created the first struts web application for the company I was working for at the
time. I went away on a 3 week honeymoon and when I came back the programer that was covering
had consolidated the list/create/delete/search/view/load/update into one action. Previously it had been
load, view/update/create, list/delete, search in three different actions. 2 years later those Actions are nightmares
to maintain since they contain multiple switch/if whose flow of control is very hard to trace.
Every time we add a new type of object some new programmer will copy the combined action
and now there are 30 very hard to maintain Actions. To make it worse the portal code has been forked
so the same code is replicated across many projects. Everyone hates working on those Actions,
not just me.


So I would recommend grouping them as load, view/update/create, list/delete, search.
The grouping is :
load is kept seperate,
take a look at the validator example in the nightly build, the editJsType, jsType actions.
to see the
pattern used to keep from replicating the load code when an error
happens and a action calls its input.
operations that operate on a single object can be grouped together(except load),
operations that work on lists of objects can be combined(except the load for a list).
search , possibly can be combined with the view/update/create.


It's true that some of the logic will be duplicated, but that logic never changes.

-Rob


I'd like to create
separate action mappings for each function.  My question is, can I
"hardcode" my dispatch parameter in the action mapping or do I have to send
it in ever request from the page?

Thanks in advance,
Graham

========================================================================
Graham Lounder - Java Developer
CARIS Spatial Components Division
[EMAIL PROTECTED]
Phone:  (506) 458-8533
Fax:    (506) 459-3849
========================================================================
NO BINDING CONTRACT WILL RESULT FROM THIS EMAIL UNTIL SUCH TIME
AS A WRITTEN DOCUMENT IS SIGNED ON BEHALF OF THE COMPANY.


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]








--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to