That doesn't sound too egregiously wrong to me... generally speaking, the code in a Struts Action should basically fall in one of two categories (or both): flow control and/or data marshalling. Some also say validation should go in the Actions, but I'm going to put that debate aside for the sake of this discussion :)

Flow control is the basic "call this class to do some processing" and then "forward to the next resource".

Data marshalling is moving input parameters into objects that will be used to do processing, and pulling data out after processing to send to the forwarded to resource.

In your case, I assume you already have some delegate class that actually reads the file? If so, one could argue the filename forming belongs there, since that class would be what needs that information... create a VO that you populate in the Action from the parameters, and pass it along to the delegate. That's probably the cleanest way because your delegate doesn't need to know anything about request parameters or anything web-related... but one could also argue that's overkill in this case (I don't think it is from an architectural perspective, but it sure is more work, and from a developer perspective I prefer to avoid that when possible!)

There's no 100% right or wrong answer, and there rarely is... best practices as best practices, not 100% all the time answers :) And it is often times very easy to over-think architecture matters like this... sometimes, 99% correct is as good as 100% (just be sure your actually at 99% and that the last 1% doesn't kill you! LOL)

Frank

Asad Habib wrote:
I have a Struts action which extracts field values from the request object and then uses these values to set the name of a file which the application reads from. The code responsible for forming the file name currently resides in the action. Is this the best place to put it? This code cannot be considered business logic but rather application logic and I would like to decouple application logic from control logic as much as possible. Is there a particular design pattern that Struts applications rely on to achieve this? Is it sufficient to simply put this code in a helper class? Any input would be appreciated. Thank you.

- Asad

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



.


--
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM/Yahoo: fzammetti
MSN: [EMAIL PROTECTED]
Author of "Practical Ajax Projects With Java Technology"
 (2006, Apress, ISBN 1-59059-695-1)
Java Web Parts - http://javawebparts.sourceforge.net
 Supplying the wheel, so you don't have to reinvent it!

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

Reply via email to