是“域对象”吗?有代表业务规则的类吗?
我遇到了“域对象”这个术语,并在 Google 上找到了几个定义,但我只是想验证我的理解是否正确。
这只是代表业务规则的任何类吗?因为“域”一词通常意味着特定于某些本地问题集的规则,例如如何计算所得税。
那么用于计算所得税的域对象将是您编写的代表所有税收规则的类?
I came across the term "domain object" and found a couple of definitions on Google but I just want to verify that my understanding is correct.
Is this simply any class that represents business rules - since the word 'domain' usually means rules that are specific to some local problem set such as how to calculate income taxes.
So the domain objects for calculating income taxes would be the classes that you write to represent all of the tax rules?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这将是一个域服务。 域对象类似于收入或纳税人。该对象可能具有一个Taxes属性,该属性调用域服务来根据例如规则计算应缴税款金额。
That would be a Domain Service. A Domain Object would be something like Income or TaxPayer. That object could have a Taxes property that calls the Domain Service to calculate the amount of taxes due according to the rules for example.
域对象是代表业务域中给定实体的任何对象。这有好几种口味。然而,一般来说,领域对象保存正在建模的实体的数据和任何规则。有些人选择在物理上分离这些问题,以便业务规则不会与数据在同一对象中进行处理。无论您选择什么实现,域对象都会以模块化方式对数据和规则进行逻辑分组。
A domain object is any object that represents a given entity in your business domain. There are several flavors of this. Generally speaking however domain objects hold data and any rules for the eitity that is being modeled. Some choose to phisically seperate these concerns so that the business rules are not processes in the same object as the data. Whatever implementation you choose domain objects logically group data and rules in a modular way.