通过Smart对象,如果属性被更改,我会考虑任何知道其原始属性值的Domain对象.智能对象通常具有基类,并通过使用GetPropertyValue/SetPropertyValue方法实现属性.另一方面,POCO对象通常没有基类并实现简单的属性.
public class SmartObject : BaseDomainObject
{
public int id
{
get { return (int)this.GetPropertyValue("Id"); }
set { this.SetPropertyValue("Id", value); }
}
}
public class POCO
{
public int id { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我喜欢Smart对象,因为它为我做了很多艰苦的工作.我可以轻松地将所有这些有用的功能添加到BaseDomainObject中,并将它们放在我的所有派生域类中:
另一方面,POCO非常简单,不依赖于任何基类.
如今我在这里赞美了很多POCO因为:
另一方面,我认为上述原因是谬误,因为:
由于这一切都很难过,我仍然喜欢那个POCO而且它让我烦恼.你有什么意见?
.net architecture domain-driven-design domain-model anemic-domain-model