Skip to content
Advertisement

Is my package structure correct?

What should be the hierarchy of packages?

com.xyz.DAO
   IDAO          (interface) 
   IPersonDAO     (interface) 
   IDepartmentDAO  (interface) 

com.xyx.DAO.impl
   PersonDAO extends GenericDAO implements IPersonDAO
   DepartmentDAO extends GenericDAO implements DepartmentDAO
   GenericDAO implements IDAO   (abstract class)
   DAOFactory 

Is this package structure appropriate?

Advertisement

Answer

I am actually against layer-driven packaging but instead I advice feature-driven approach:

com.xyz
   IDAO          (interface) 
   GenericDAO implemts IDAO   (abstract class)
   DAOFactory 
com.xyz.person
   IPersonDAO     (interface) 
   PersonDAO extends GenericDAO implements IPersonDAO
com.xyx.department
   IDepartmentDAO  (interface) 
   DepartmentDAO extends GenericDAO implemts DepartmentDAO

The reasoning is: you’ll much more often want to have all classes related to person functionality in one place. Not often you need all DAO classes.

UML
(source: yuml.me)

10 People found this is helpful
Advertisement