Hi all,
I had this questions since the time I learnt about object-oriented programming. Now, I have got a wonderful forum I thought of asking this.
Lets say we are implementing an employee management application using EJB.
Now, there are 2 ways of doing this.
Normally, we create entities (POJOs) which represent an employee. Then we create an EJB interface 'EmployeeManager' with add, delete, update, retrieve, retrieveAll methods. This way I could use 'employee' entity as a data transfer object.
We call the EJB interface itself 'Employee'. Implementation could be called 'EmployeeImpl' which has fields as well as method implementation (add, delete, update, retrieve, retrieveAll). If I am using a layered approach where my business logic needs access to employee details, I need to pass 'EmployeeImpl' (because it contains values).
Which one do you think is the better way?
I prefer the first one, because it 'looks' fine and does not feel awkward. like
EmployeeMgr empMgr = // JNDI lookup;
Employee emp = new Employee();
empMgr.add(emp);
Employee employees[] = empMgr.retrieveAll();
Where as the second one would look like (though I am not sure),
Employee emp = // JNDI lookup;
emp.setName(); //set the properties
emp.add();
Employee employees[] = emp.retrieveAll();
As you can see, the second one looks awkward.
I request you guys to advise me on this.
Thanks manju