DDD:SO标签。实体还是值类型? [英] DDD: SO tag. An Entity or value type?
本文介绍了DDD:SO标签。实体还是值类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在域驱动设计的上下文中,StackOverflow标记(即 ddd )是值对象还是实体?
In the context of Domain Driven Design, is a StackOverflow tag (ie. ddd ) a value object or entity?
编辑:
想象一下,您必须建立SO网站。
Imagine, that you have to build SO website. How would you consider 'tag'?
推荐答案
在awhite的答案上稍微扩展一下
a标签是一个值类型
为什么?
因为没有意义
To expand a little on awhite's answer a tag is a value type Why? Because it doesn't make sense to have
var tag1 = new Tag("DDD");
var tag2 = new Tag("DDD");
Assert.AreNotEqual(tag1, tag2);
显然,它们应该彼此相等,因为标签除了其标签外没有其他身份。另一方面,问题和答案肯定是实体
clearly they should be equal to each other because a tag has no identity except for its label. Questions and answers on the other hand are definitely entities
这篇关于DDD:SO标签。实体还是值类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文