值对象与实体

发布于 2024-09-07 05:32:21 字数 221 浏览 2 评论 0原文

简单的问题......当处理像电子邮件地址这样的东西时,直接的想法是将其视为一个值对象。

但是,如果我们有多个实体(例如客户、联系人和供应商)引用相同的电子邮件地址,则可以想象,当我们更改客户的电子邮件地址时,我们可能需要客户的联系人,并且他们可能是供应商也应将电子邮件更改反映到这些实体中。我是否正确地认为这给出了电子邮件地址身份,因此它现在应该表示为一个实体?

干杯,

史蒂夫

Quick question... When approaching something like an email address the immediate idea is to treat this as a value object.

If we have a number of entities though, say a customer, a contact, and a supplier that are referencing the same email address, it is conceivable that when we change a customer's email address we may want the customer's contact, and they may be a supplier too, have that email change reflected with those entities as well. Am I correct in thinking this is giving the email address identity so it should now be represented as an entity?

Cheers,

Steve

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

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

发布评论

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

评论(1

〃温暖了心ぐ 2024-09-14 05:32:21

是的,我相信你的做法是正确的。请参阅我之前的回答此处

Yes, I believe you're on the right lines. See my previous answer here.

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