aspose file tools*
The moose likes Struts and the fly likes How many Actions should I use in my application? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How many Actions should I use in my application?" Watch "How many Actions should I use in my application?" New topic
Author

How many Actions should I use in my application?

bhargav shankar
Greenhorn

Joined: Jan 10, 2008
Posts: 8
Hi,

I need to develop an application it demands lots of tasks in it. so how should i develop my struts application?

1 should I use one action for each task. ( loose coupling)

2. I use Only one Action for all the tasks ( tight coupling) . using something like url.do?method='task' and
checking the method in if condition of the execute method. and implementing the logic there in the if block. and forwarding request to that perticular forward

which is the better way and why?

Thanks
Bhargavshankar


bhargav
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

First thing first, never make all the business logic in single or few Action classes, make separate Action class for separate logical business activity.
bhargav shankar wrote:using something like url.do?method='task' and
checking the method in if condition of the execute method. and implementing the logic there in the if block. and forwarding request to that perticular forward

You should look for the Struts Dispatch Action for this.
http://www.jguru.com/faq/view.jsp?EID=897290


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
bhargav shankar
Greenhorn

Joined: Jan 10, 2008
Posts: 8
Sagar Rohankar wrote:First thing first, never make all the business logic in single or few Action classes, make separate Action class for separate logical business activity.


is there any reason behind this? Could you explain why?
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

bhargav shankar wrote:
Sagar Rohankar wrote:First thing first, never make all the business logic in single or few Action classes, make separate Action class for separate logical business activity.


is there any reason behind this? Could you explain why?


Don't you think jumbling all the programming logic in one class and making it 2000 LOC (If your app is large having more than 10 pages) and separation each action using multiple if..else statement which is considered as bad programming practice.
Its hard to maintain such code (google for agility development process) to change the single line of code you have to search thousands of line of code just to get there. Separation is good thing.

I'm not experienced and not guru in development, see what other rancher have to say about this.
bhargav shankar
Greenhorn

Joined: Jan 10, 2008
Posts: 8
Thanks for your information sagar,
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

If that helps you, then welcome
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How many Actions should I use in my application?