what is BUSINESS DELIGATE PATTERN,DAO,VO,DTO?

Answer Posted / kathiravan j

Let's say I have three tables:

Employee (contains employee_id, employee_name, and dept_id)
Department (contains dept_id, dept_name, loc_id)
Location (contains loc_id, location_name)

How deep do your classes go to replicate the data?
Do you do this...

public class Employee {
private int id;
private String name;
private int deptId; // just the id

// .. implementation details
}

or do you do this

public class Employee {
private int id;
private String name;
private Department dept; // all of the data

// .. implementation details
}

and so on and so on. Class Department has the same type of
problem. Does it hold just the id for location or a
variable class Location?

Should DAOs just fill in the id (keys) so it is up to the
application using the DAOs to get the Employee class, then
the Department class, and the the Location class like:

Employee emp = EmployeDAO.getEmployee(1);
Department dept = DepartmentDAO.getDepartment(emp.getDeptId
());
Location loc = LocationDAO.getLocation(dept.getLocId());
System.out.println(emp.getEmpName() + " works in " +
loc.getLocationName());

or

Employee emp = EmployeDAO.getEmployee(1);
System.out.println(emp.getEmpName() + " works in " +
emp.getDept().getLoc().getLocationName());

Now this is just a simple example, but where do you draw
the line? It's possible to go on and on and on and cycle
back to employee... Taking another approach to the same
question...Say I have an employee_type table having values
of fulltime, parttime, etc. Whay do you store in the
employee class now? Just a String with the value of the
type or the key to the employee_type table? Is it
application dependent?

Is This Answer Correct ?    10 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the benefits of Interceptors in Struts2?

644


State the procedure for using forward attribute of link tag’s.

534


What is the forward action utilized for?

548


Describe the two types of formbeans.

571


How to work with error tags?

558






What are the steps involved in creating a strut application?

510


Does apache struts run on windows?

528


Why do we need mapdispatchtoprops?

473


What is the difference between struts1 and struts2?

512


What do you mean by actionmapping?

529


What helpers in the form of jsp pages are provided in struts framework?

525


What is the purpose of @requiredstringvalidator annotation?

527


Explain the life cycle of a request in struct2 application?

488


What is the design role played by struts?

550


Does struts include its own unit tests?

518