  | Mailing List | | Home | | Forum Home | | JBoss - Java Application Server | | Tomcat - JSP/Servlet container | | Struts - A MVC web framework | | iText - An open source PDF Java Library | | JDOM - JDOM XML Parser | | JSP - A mailing list about Java Server Pages specification and reference | | J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition | | J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog | | Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology | |
Struts & Hibernate
|
|
|
  | | | Need feedback on design approach | Need feedback on design approach 2004-08-20 - By Prasanna Kumar B.P[SLK/IND]
Back All, This mail is too lengthy. Sorry for that.
I need your suggestions/feedback on the below design approaches.
Requirement: Employee details need to be created and displayed in a system. An Employee can 1. have multiple addresses(home, communication etc) 2. belong to a department 3. have multiple dependents
For the above requirements design approach could be
Process 1: Create Employee -- ---- ---- ---- ---- ---- ---- Design#1: Create a DAO class EmployeeDAO that will have methods like a) addEmployee(emp_id) b) addAddress(Address,type) c) addDepatment(department) d) addDependent(dep_name[])
This DAO will be called by my BO/SF repeatedly to create an employee.
Design#2:Create a DAO class EmployeeDAO that will have only ONE method taking all details as parameters addEmployee(emp_id, department, dep_name[], Address[] )
This addEmployee() will call a stored procedure to create ENTIRE employee details, passing entire employee details as Arrays.
Process 2: Get entire employee details to diplay on screen -- ---- ---- ---- ---- ---- ---- ---- ----- Design 1: EmployeeDAO will have methods like a) getEmployeeName(emp_id) b) getEmployeeAddress(emp_id) c) getDepartment(emp_id) d) getDependants(emp_id)
This DAO will be called by my BO/SF repeatedly to to construct DTO object containing entire employee information.
Design 2: EmployeeDAO will have only one method getEmployeeDetails() which returns DTO containing entire employee detail. This method in turn will call a stored procedure which returns multiple cursors containing employee information.
Now, What do you feel ? Which approach is correct ? Please consider maintainability and performance also into consideration.
Thanks in advance, Prasanna -- ---- ---- ---- ---- ---- ----
==================================================================== Companion Site: http://www.corej2eepatterns.com J2EE BluePrints: http://java.sun.com/blueprints/corej2eepatterns List Archive: http://archives.java.sun.com/archives/j2eepatterns-interest.html Unsubscribing: email "signoff J2EEPATTERNS-INTEREST" to listserv@(protected)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859 (See http://iso-8859.ora-code.com)-1">
<META content="MSHTML 6.00.2600.0" name=GENERATOR></HEAD> <BODY> <DIV><FONT face=Tahoma><FONT size=2>All,<BR>This mail is too lengthy. Sorry for that.<SPAN class=205133212-20082004> </SPAN></FONT></FONT></DIV> <DIV><FONT face=Tahoma size=2></FONT> </DIV> <DIV><FONT face=Tahoma size=2>I need your suggestions/feedback on the below design approaches. </FONT></DIV> <DIV><FONT face=Tahoma size=2></FONT> </DIV> <DIV><FONT face=Tahoma size=2><STRONG>Requirement</STRONG>: Employee details need to be <SPAN class=205133212-20082004>created and </SPAN>displayed in a system. An Employee can <BR>1. have multiple addresses(home, communication etc) <BR>2. belong to a department<BR>3. have <SPAN class=205133212-20082004>multiple </SPAN>dependents </FONT></DIV> <DIV><FONT face=Tahoma size=2></FONT> </DIV> <DIV><FONT face=Tahoma size=2>For the above requirements design approach could be </FONT></DIV> <DIV> </DIV> <DIV><FONT face=Tahoma size=2><STRONG>Process 1: Create Employee<BR></STRONG>-- ---- ---- ---- ---- ---- ----<BR><STRONG>Design#1< /STRONG>: Create a DAO class EmployeeDAO that will have methods like<BR> a) addEmployee(emp_id)<BR> b) addAddress(Address,type)<BR> c) addDepatment(department)<BR> d) addDependent(dep_name[])<BR> <BR> This DAO will be called by my BO /SF repeatedly to create an employee. </FONT></DIV> <DIV><FONT face=Tahoma size=2></FONT> </DIV> <DIV><FONT face=Tahoma size=2><STRONG>Design#2</STRONG>:Create a DAO class EmployeeDAO that will have only ONE method <SPAN class=205133212-20082004>taking all details as parameters</SPAN><BR> addEmployee(emp_id, department, dep_name[], Address[ ] )</FONT></DIV> <DIV><FONT face=Tahoma size=2></FONT> </DIV> <DIV><FONT face=Tahoma size=2> This addEmployee() will call a stored procedure to create ENTIRE employee details, passing entire employee details as Arrays.<BR> <BR> <BR><STRONG>Process 2: <SPAN class=205133212-20082004>Get </SPAN>entire employee details<SPAN class=205133212-20082004> to diplay on screen</SPAN></STRONG><BR>-- ---- ---- ---- ---- ---- ---- ---- -----<BR> <STRONG>Design 1</STRONG>: EmployeeDAO will have methods like<BR> a) getEmployeeName(emp_id)<BR> b) getEmployeeAddress(emp_id)<BR> c) getDepartment(emp_id)<BR> d) getDependants(emp_id)</FONT></DIV> <DIV> </DIV> <DIV><FONT face=Tahoma size=2> This DAO will be called by my BO/SF repeatedly to to construct DTO object containing entire employee information.<BR> <BR><STRONG>Design 2</STRONG>: EmployeeDAO will have only one method getEmployeeDetails() which returns DTO containing entire employee detail. <STRONG>This method in turn will call a stored procedure which returns multiple cursors containing employee information</STRONG>.</FONT></DIV> <DIV><FONT face=Tahoma size=2></FONT> </DIV> <DIV><BR><FONT face=Tahoma size=2>Now, What do you feel ? Which approach is correct ? Please consider maintainability and performance also into consideration.</FONT></DIV> <DIV><FONT face=Tahoma size=2></FONT> </DIV> <DIV><SPAN class=205133212-20082004></SPAN><FONT face=Tahoma size=2>T<SPAN class=205133212-20082004>hanks in advance,</SPAN></FONT></DIV> <DIV><FONT face=Tahoma size=2><SPAN class=205133212-20082004>Prasanna</SPAN></FONT></DIV> <DIV><FONT face=Tahoma size=2><SPAN class=205133212-20082004>-- ---- ---- ---- ---- ---- ----</SPAN></FONT></DIV> <DIV><FONT face=Tahoma size=2><SPAN class=205133212-20082004></SPAN></FONT> </DIV> <DIV><FONT face=Tahoma size=2><SPAN class=205133212-20082004></SPAN> </DIV> <DIV><BR> </FONT></DIV></BODY></HTML> ==================================================================== Companion Site: http://www.corej2eepatterns.com J2EE BluePrints: http://java.sun.com/blueprints/corej2eepatterns List Archive: http://archives.java.sun.com/archives/j2eepatterns-interest.html Unsubscribing: email "signoff J2EEPATTERNS-INTEREST" to listserv@(protected)
|
|
 |