服务层建议
我对服务层有一些疑问。我有一些名为 EmployeeDAO、ProjectDAO 等的 DAO。 现在访问这些 DAO 的最佳方式是什么?我应该为每个 DAO 创建单独的服务层还是创建一个包含所有 DAO 的公共服务层。 我想在这里使用 spring 。 考虑加载bean和performanche,哪个好?
I have some queries regarding the service layers. I have some DAOs called EmployeeDAO,ProjectDAO,etc.
Now which is the best way to access these DAOs? Should I create seperate Service layers for each DAOs or create a common Service layer which will have all the DAOs.
I would like to use spring here.
considering loading the beans and performanche, which is good?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为最好将事情分开,例如
EmployeeService
,ProjectService
等。我认为最好将事情分解。想象一下,如果您有一些两者通用的方法,因此您使用相同的方法来访问Employee
数据和Project
数据。现在,在您的项目几个月后,Employee
数据发生了一些变化,但Project
数据没有变化。您必须对代码进行重构,就Project
数据而言,这是不需要的。分解事情应该可以让你更好地维护系统。
I think that it would be best if you split things up, for instance
EmployeeService
,ProjectService
, etc. I think it is better to break things down. Imagine if you have some methods which are common to both, so you use the same method(s) to access both theEmployee
data and theProject
data. Now, a few months in your project, something changes to theEmployee
data, but not to theProject
data. You will have to do a refactoring of code which, as far as theProject
data is concerned, is not needed.Breaking things down should allow you to maintain the system better.