包的层次结构应该是什么?
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
此包结构是否合适?
答案 0 :(得分:3)
我实际上反对图层驱动的打包,而是建议使用功能驱动的方法:
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
原因是:您经常希望在一个地方拥有与 person 功能相关的所有课程。通常不需要所有DAO课程。