aspose file tools
The moose likes Java in General and the fly likes Question about class naming Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Question about class naming" Watch "Question about class naming" New topic
Author

Question about class naming

Oscar Calderon
Ranch Hand

Joined: Nov 27, 2009
Posts: 32
Hi to all, probably this question can sound a little bit stupid, but i have the next doubt: I'm doing a webapp using Struts 2, and if you know, in struts 2 you create actions, interceptors, jsp (or some other view technology) and so on. This applies the MVC where View is the view technology like JSP or velocity, Controller is the internal Struts servlets that handle all the requests and the Model are the action classes where you define the application logic when somebody makes a request to Struts Action.

For example if i have a simple CRUD application in my action i can have the methods for update, delete, insert and select. The problem here is that i have to put (consider that i'm not using anything like hibernate or some orm, just JDBC ) all the code with the sql query, statements, resultset and so on inside each action's method. My question is, that to separate that from my actions i want to create classes used by my actions, for example if i have a employees mantainment i have my action EmployeesAction and inside it's methods of insert, delete select and so on i only call the insert method from other class. That "other class" is something like a DAO but i prefeer don't call in that way because i'm not applying the DAO concept at all, so MY QUESTION IS: How can i name those classes? for example if i apply DAO my class could be named like EmployeeDAO, but in my case how can i call it?

Thanks in advance.


Wanna grow? Learn, live, love people and enjoy life
Mazer Lao Tzu
Ranch Hand

Joined: Jan 20, 2010
Posts: 35
I have seen these classes called Managers, such as EmployeeManager.



-- Mazer
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Oscar Calderon wrote:Controller is the internal Struts servlets that handle all the requests and the Model are the action classes where you define the application logic when somebody makes a request to Struts Action.

Just for completeness, S2 uses a filter, not a servlet.
in my case how can i call it?

I'm not entirely sure what you're asking, but they might also be called services.
Oscar Calderon
Ranch Hand

Joined: Nov 27, 2009
Posts: 32
Well, about the filter, i didn't know that. Thanks for the acclaration.

About "in my case how can i call it?" i mean about how to name my classes, as DAO are named EmployeeDAO, SomethingDAO and so on.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

You've already been given two options, "manager" and "service".
Oscar Calderon
Ranch Hand

Joined: Nov 27, 2009
Posts: 32
Ok, thanks to both for your answers
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Question about class naming
 
Similar Threads
Structure for Data Access Object(s)
using static methods
Problem with Struts 2
Is it Okay if a DAO class is made as Singleton
Is it ok to make a DAO class as Singleton