使用 DDD 时避免 getter 并使用 DTO 来检索信息
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看看 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