Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
基于这个答案,我发现贫血域模型背后的相同想法正在积极记录中!在活动记录模式中,数据库字段与域属性相同(如果我错了,请纠正我),所以根据我之前提到的答案,我们在贫血模型中也有相同的(很容易从数据库表中自动生成),那又如何这两种方法有什么区别?谢谢
这是 Martin Fowler 的企业应用程序架构模式中对 Active Record 的官方一句话定义:
“在数据库表或视图中包装一行、封装数据库访问并在该数据上添加域逻辑的对象。” (强调我的)
请注意我加粗的定义的最后一部分。由于 Active Record 应该向该类添加额外的域逻辑,因此它并不乏力。