使用 DDD 时避免 getter 并使用 DTO 来检索信息

发布于 2024-09-15 13:47:36 字数 263 浏览 3 评论 0原文

Greg Young 谈论关于在使用领域驱动设计时避免域对象上的 getter 和 setter 。对于我希望将持久存储中的信息呈现到屏幕上的用例,遵循此架构模式时对象模型会是什么样子?

我是否期望看到直接从存储库检索 DTO,或者可能是独立的 DtoService,将 Dto 实例直接提供给“UI 层”(例如控制器)?

Greg Young talks about avoiding getters and setters on domain objects when using Domain Driven Design. For the use case where I want information from a persistent store to be rendered to the screen, what would the object model look like when following this architectural pattern?

Would I expect to see a DTO being retrieved directly from a repository, or perhaps an independent DtoService, supplying the Dto instances directly to the "UI layer" (say a controller)?

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

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

发布评论

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

评论(1

不必你懂 2024-09-22 13:47:36

看看 CQRS;概念是您将从报告服务或报告视图特定数据存储返回特定于视图的 DTO

Have a look at CQRS; notion would be that you would return a view specific DTO either from a reporting service or reporting view specific datastore

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