i am woring with a struts application.
like add a employee and edit the employee and delete the record like.
is it better to write one action class for all of the above actions or
to write individual actions for individual ones..
clearly tell me the relation between the performence and the number of action classes
Yous should user one form (EmplyeeForm) and more actions (AddEmployeeAction, EditEmployeeAction, GetEmployeeAction, DeleteEmployeAction). Extracting common logic in a BaseEmployeeAction might improve things.
Personally I would use one form but use DispatchAction or Lookup Action and only have one Action class. That way your code that is commonly used is in one place instead of the Action class with only execute method.
Like Mircea, I prefer one Action class to do one thing and one
thing only. You can put common stuff in a Base Action class as
I'm not a big fan of the one Action class that does everything.
It almost strikes me as the Magic Servlet anti-pattern.
To each his own I guess.
Well, I disagree with that because you don't write a bean that simply gets your property. The action class should be within a simple business domain. CRUD (Create, Read, Update, Delete) operations all fall under one operation on an object. You don't create a different database object to read, one to update and one to delete.
The multiple Action class thing that does CRUD operations just leads to more classes to maintain for no reason. But then again I'm not a believer in the Base Action either.