What should be the hierarchy of packages?
JavaScript
x
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:
JavaScript
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.
(source: yuml.me)