是仓库图案相同的Active Record模式? [英] Is Repository pattern as same as Active Record pattern?

查看:166
本文介绍了是仓库图案相同的Active Record模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

它们似乎是相似的。

推荐答案

他们是不同的。

活动记录模式定义的对象,它包装在一个数据库中表或视图中的行,封装了数据访问,并添加域逻辑上的数据。

Active Record Pattern defines An object that wraps a row in a database table or view, encapsulates the data access, and adds domain logic on that data.

在库模式所有的数据访问放在一个单独的类,并通过实例方法进行访问。对我来说,只是这样做是有利的,因为数据访问现在封装在一个单独的类,使业务对象获得与业务。你会得到与活动记录本应该停止的数据访问和业务逻辑的不幸混合。

In the Repository pattern all of the data access is put in a separate class and is accessed via instance methods. To me, just doing this is beneficial, since data access is now encapsulated in a separate class, leaving the business object to get on with business. This should stop the unfortunate mixing of data access and business logic you tend to get with Active Record.

检查该链接了解:

<一个href="http://moleseyhill.com/blog/2009/07/13/active-record-verses-repository/">http://moleseyhill.com/blog/2009/07/13/active-record-verses-repository/

这篇关于是仓库图案相同的Active Record模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆