什么构成了POJO/POCO中的富域模型? [英] What constitutes a rich domain model in a POJO/POCO?
问题描述
两者之间有什么区别
- 一个简单的 fields-accesors-mutators 类
- 丰富的课程
什么构成了业务领域类中的丰富建模?
What constitutes rich modeling in business-domain classes?
推荐答案
此处使用的丰富"表示丰富行为"(与状态相对).
"Rich" as used here implies "rich behavior" (as opposed to state).
存在技术行为和领域行为. accessors 和 mutators 是技术性的;他们缺少定义业务兴趣的为什么".
There is technical behavior and domain behavior. Accessors and mutators are technical; they lack the "why" which defines business interest.
域对象表示为什么"并封装方式".实际上,所有对象都可以这样做.域对象专门为业务价值而做.
Domain objects represent the "why" and encapsulate the "how". Actually, all objects do that; domain objects do it specifically for business value.
比方说,作为雇员的域对象,您必须要求请假一天.您有2个选择:
Let's say you, as an employee domain object, have to request a day off of work. You have 2 options:
- 告诉您的经理,他会安排时间表.
- 向您的经理询问时间表并标记时间表.
模型1丰富. 为什么"(休假时间)封装了如何"(标明时间表).
Model 1 is rich. The "why" (vacation time) encapsulates the "how" (marking the schedule).
模型2将经理委派给一个简单的属性包,并泄漏了调度抽象.
Model 2 relegates the manager to a simple property bag and leaks the scheduling abstraction.
这篇关于什么构成了POJO/POCO中的富域模型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!