我可以将富域模型与 WCF 一起使用吗?

发布于 2024-08-13 04:28:41 字数 345 浏览 1 评论 0原文

是否可以使用 DDD 和富域模型

  • 如果您的应用程序类似于: Windows 客户端 (WPF)
  • Windows 服务

并且与 WCF 进行通信,

?我习惯于使用仅包含数据状态的 DTO,并在服务层内包含业务规则,但每个人都不断告诉我,我应该拥有一个丰富的域模型,其中数据状态和规则/方法都位于对象本身中。

我只是不确定这个丰富的域模型是否适用于具有 UI 并通过 WCF 与服务通信的系统(就像我上面介绍的那样)。就我而言,由于 WCF,是否继续使用贫血域模型会更好?如果没有,您能否举例说明如何使用富域模型来构建它,并考虑 WCF、代理等?

谢谢!

Is it possible to use DDD and a rich domain model if your application is like:

  • windows client (WPF)
  • windows service

And communication happens with WCF?

I'm used to have DTO's with only data state, and have business rules inside the Service layer, but everyone keeps telling me that I should have a rich domain model where data state and rules/methods are all in the objects themselves.

I'm just not sure if this rich domain model would apply to a system that has a UI and communicates via WCF to a service (like I presented above). In my case is it better to continue using an anemic domain model because of WCF? If not, could you please give an example on how to architecture it using a rich domain model, considering WCF, proxy, etc?

Thanks!

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

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

发布评论

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

评论(1

指尖微凉心微凉 2024-08-20 04:28:41

Generally speaking you serialize your domain objects for transmission across WCF as some simplified DTO anyway, and it's these that are consumed by your client application.

You can serialize user defined types and deserialize them in the client but for most applications this is unnecessary. As long as you don't need the 'rich' behaviour of your objects in your client (which you shouldn't with a good DDD anyway), it sounds to me like you are fine to use a rich design in your service layer and send simple DTOs across the wire.

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