更新时间:2023-01-12 20:01:08
actionPerformed()
方法处理事务.它明显违反了DAO/服务层的目的 UserService
正在接受 AbstractDAO
,这意味着其他一些代码可能会将错误的DAO实现传递给您的 UserService
,这会使事情搞砸actionPerformed()
method. Its clearly defeating the purpose of DAO/Service layerUserService
is accepting AbstractDAO
, which means some other code may pass wrong DAO implementation to your UserService
that will screw things up现在,很少有建议.
Service
, DAO
和 BusinessDelegate
.因此,问问自己是不是真的回答了您的某些问题.如果没有,请摆脱它们.YAGNI Service
, DAO
and BusinessDelegate
. So, question yourself are any of these really answering some of your questions. If not, get rid of them. YAGNI[已编辑]
编辑后,我的第3条建议没有多大用处.顺便说一下,您将DAO命名如下: UserJdbcDAO
, UserMysqlDAO
等.您的第二个名字意义不大,因为我们使用ORM只是为了避免数据库供应商特定的DAO/查询.如果您的 UserMysqlDAO扩展了UserJdbcDAO
,这可能会变得有些道理.
After your edit my 3rd suggestion doesn't carry much weight. By the way, you name your DAOs as follows; UserJdbcDAO
, UserMysqlDAO
etc. Your 2nd name is not making much sense, as we use ORMs just to avoid DB vendor specific DAOs/queries. It might start making some sense if your UserMysqlDAO extends UserJdbcDAO
.