ddd-值对象以覆盖每个属性 [英] ddd - value objects to cover every property

查看:53
本文介绍了ddd-值对象以覆盖每个属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

实现与第三方系统的集成,该系统可以从网站导出产品和导入订单。

Implementing an integration with a 3rd party system which exports products and imports orders from a web site.

在设计中已经完成了一些ddd工作,并继续进行

There is some ddd work already done in the design and to continue it i would like.

订单和产品上的每个属性都应包含值对象吗?

Should every single property on the order and products be covered with a value object?

这将意味着大约100个类,以覆盖似乎过剩的所有可能的属性:

This would mean around 100 classes to cover all possible properties which seems excessive:


  • ProductSku

  • ProductName

  • ProductDescription

  • ProductPrice

  • etc ...

  • ProductSku
  • ProductName
  • ProductDescription
  • ProductPrice
  • etc...

推荐答案


订单和产品上的每个属性都应包含
a值对象吗? / p>

Should every single property on the order and products be covered with a value object?

在我知道的任何语言中,原始值已经是一个值对象:不可变且没有标识(即字符串,数字等)。

In any language that I know a primitive value is already a value object: immutable and without an identity (i.e. strings, numbers etc).

如果您指的是我应该创建一个新类来包含该数据和行为,那么我说YAGNI。如果找不到执行此操作的充分理由(您需要强类型键入,将隐式显示为显式等),请不要立即执行此操作。等到您将需要它。

If you are referring to "Should I create a new class to encompass that data + behavior" then I say YAGNI. If you can't find a good reason to do it (you need strong typing, you make the implicit explicit etc) then don't do it right now. Wait until you will gonna need it.

这篇关于ddd-值对象以覆盖每个属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆