我可以将富域模型与 WCF 一起使用吗?
是否可以使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一般来说,无论如何,您都将域对象序列化为跨 WCF 传输作为某种简化的 DTO,并且这些对象由您的客户端应用程序使用。
您可以序列化用户定义的类型 并在客户端中反序列化它们,但对于大多数应用程序来说这是不必要的。只要您不需要客户端中对象的“丰富”行为(无论如何您都不应该使用良好的 DDD),在我看来,您可以在服务层中使用丰富的设计,并且通过线路发送简单的 DTO。
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.