服务层建议

发布于 2025-01-05 06:18:34 字数 161 浏览 4 评论 0原文

我对服务层有一些疑问。我有一些名为 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

但可醉心 2025-01-12 06:18:34

我认为最好将事情分开,例如EmployeeServiceProjectService等。我认为最好将事情分解。想象一下,如果您有一些两者通用的方法,因此您使用相同的方法来访问 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 the Employee data and the Project data. Now, a few months in your project, something changes to the Employee data, but not to the Project data. You will have to do a refactoring of code which, as far as the Project data is concerned, is not needed.

Breaking things down should allow you to maintain the system better.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文