本文介绍了在域驱动设计中,您可以在UI中使用域实体吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在许多领先的DDD项目中,尤其是MVC风格中,我看到UI使用的是反映域实体的显示对象,而不是直接使用这些域对象.显然,这种样式用于分离和分离关注点,我个人更喜欢这种样式.

In many leading DDD projects, especially MVC style, I see the UI using display objects that mirror domain entities, rather than using those domain objects directly. This style is obviously for decoupling and separation of concerns, and I personally prefer this style.

但是我不确定这是DDD的严格原则,还是仅仅是开发人员对DDD的不同解释.

But what I'm not sure of, is whether this a strict tenet of DDD, or whether this is more just different developers' interpretation of it.

您可以直接在UI中使用您的域对象,并且仍然遵循DDD方法吗?

Can you use your domain objects directly in the UI, and still be following the DDD methodology in that act?

还是总是使用显示对象的DDD最佳实践?

Or is it a DDD best practice to always use display objects?

注意:虽然我提到了MVC,但我对是否必须在DDD项目中的几乎所有DDD兼容UI模式中使用显示对象很感兴趣.

Note: While I mention MVC, I'm really interested in whether display objects must be used in almost all DDD compatible UI patterns in a DDD project.

推荐答案

DDD是在设计从建模域开始的软件时的一种思考方式.正如网页所述:

DDD is a way of thinking while designing a software that starts with modelling the domain. As the webpage puts it:

自然而然地遵循此设计模式的一件事是分层体系结构.如 DDD模式摘要

One thing that follows naturally out of this design pattern is a layered architecture. As it is said in DDD Pattern Summaries

是否需要显示对象才能执行此操作?那只是实现此目的的一种方法,但可能甚至不是提供松散耦合的最佳方法.举个例子:也许视图层不过是一个Web浏览器和xlt文件,以可视化业务层发出的xml文件?如果有人有更多合适的示例,请添加它们.我的观点是DDD强调了分层体系结构,但并不限于一种可能的解决方案.

Whether you need to have display objects to do that? That is just one way of implementing this, but might not even be the best to provide loose coupling. As for an example: maybe the view layer is but a webbrowser and xlt files to visualize xml files emmitted by the business layer? If anybody has more fitting examples, please add them. My point is that DDD stresses a layered architecture, but does not limit this to one possible solution.

这篇关于在域驱动设计中,您可以在UI中使用域实体吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-24 21:44