0

包的层次结构应该是什么?

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 

这个包结构合适吗?

4

1 回答 1

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

原因是:您更经常希望将与人员功能相关的所有类放在一个地方。您并不经常需要所有 DAO 类。

UML
(来源:yuml.me

于 2012-07-30T16:52:51.720 回答