Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How many Actions should I use in my application?

 
bhargav shankar
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Sagar Rohankar
Ranch Hand
Posts: 2906
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
bhargav shankar
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2906
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your information sagar,
 
Sagar Rohankar
Ranch Hand
Posts: 2906
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If that helps you, then welcome
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic