struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Hill" <andrew.david.h...@gridnode.com>
Subject RE: is Struts action class a Design Pattern of utility class?
Date Wed, 16 Jul 2003 14:37:35 GMT
You shouldnt be using (modifiable) instance methods in an Action class as
actions need to be threadsafe - remember that could be any number of threads
executing that code at the same time! (This is where request attributes come
in handy) so certainly you should be eliminating instance variables and
either declaring them as local and passing between your methods or shoving
them in a bean you pass between your methods or putting them in request
attributes...

As for making your methods static... you probably dont want to do that - you
will be choking off your ability to subclass your action amoung other
things. Take a look in the archive at the discussion last week about
singletons vs statics.

Actions are a helper class not a utility class. They are invoked by the
RequestProcessor to assist it in processing the use case specific logic of
the action.

-----Original Message-----
From: Denis Wang [mailto:dwang@brandmuscle.com]
Sent: Wednesday, 16 July 2003 22:29
To: Struts Users Mailing List
Subject: is Struts action class a Design Pattern of utility class?


Hello, all,
I am not sure whether it is a good practice to:
eliminate instance variables from Struts action class; and
make all methods static.
Basically it turns the action class into a utility class.
Any comments?  Thanks.
Denis


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Mime
View raw message