MVC。实施模型布局。我的最终解决方案。成功?

发布于 2024-12-29 09:08:22 字数 722 浏览 7 评论 0原文

在开始实施模型布局之前,我在此网站上问几个问题:

正确的设计对于实体类。需要建议

Java 泛型。对我来说有什么好处?

两个类内部几乎有重复的代码

用户给了我很多好的、完美的推荐。

结果,我为模型布局创建了下一个实现: 在此处输入图像描述

您能看一下我的屏幕截图吗?并告诉我,

我正确理解了一切? 我的实施成功了吗?

兰格图像上的PS链接:http://www.dropmocks.com/mBf62w

Before start work on implementation Model layout, I ask few question on this site:

Correct design for entity classes. Need recommendations

Java Generics. What benefit in my case?

and

Two classes with almost duplicate code inside

Users give me many good and perfect recommendations.

In result, I create next implementation for my Model Layout:
enter image description here

Can you please look on my screenshot. And tell me,

I correct understang all?
And my implementation success?

P.S. link on lange image: http://www.dropmocks.com/mBf62w

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

尝蛊 2025-01-05 09:08:23

当我使用 hibernate 时,我不关心 dao,似乎没有必要/多余,只有实体和服务层(以及控制器和视图)。

然而,对于这个

I don't bother with a dao when I use hibernate, seems unnecessary/superfluous and just have entities and a service layer (and a controller and view).

There are however differing views on this.

笑咖 2025-01-05 09:08:22

您的解决方案还缺少一件事,那就是服务层。这很重要,因为您将在服务层中使用 DAO 来执行某些业务逻辑。通常数据库事务也在服务层上定义,因此请记住这一点。

我还会摆脱 Persistent 接口,因为我看不出它有什么帮助,相反 - 我会使用 PersistentImpl 的抽象类。那么 AbstractEntity 会是更合适的名称。

除此之外 - 你的解决方案整洁干净 - 我在我的几个项目中使用它,我对此非常满意:)

Your solution lacks of one more thing, which is Service Layer. This is important, since you will use DAOs within the service layer to perform some business logic. Usually Database Transactions are also defined on the service layer, so keep that in mind.

I would also get rid of Persistent interface, since I don't see how it helps in anything, and instead - I would use abstract class for PersistentImpl. AbstractEntity would be more appropriate name then.

Other than that - your solution is neat and clean - I'm using it across several project of mine and I'm very happy with it :)

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