DAO 和 DAL 有什么区别?
在学校学习过 Java 后,我对 DAO 模式非常熟悉(数据访问对象)。 然而在工作中我使用.NET。 在 .NET 中,经常讨论 DAL(数据访问层)。 对我来说,他们的目的似乎非常相似。 那么问题是 DAO 和 DAL 基本上是一样的吗? DAL 一词是否只是为了避免与数据访问对象混淆而编造的?
Having studied Java at school I am quite familiar with the DAO-pattern(Data access object). However at work I use .NET. In .NET there is often talk about the DAL(Data Access Layer). To me their purpose seems quite similar. So the question is are DAO and DAL basically the same thing? Is the term DAL only made up so it wouldn't be mixed up with Data Access Objects?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
数据访问层(DAL)是存在于业务逻辑层和持久/存储层之间的系统层。 DAL 可能是单个类,也可能由多个数据访问对象 (DAO) 组成。 它可能在顶部有一个外观供业务层与之通信,隐藏数据访问逻辑的复杂性。 它可能是第三方对象关系映射工具 (ORM),例如 Hibernate。
DAL 是一个架构术语,DAO 是一个设计细节。
The Data Access Layer (DAL) is the layer of a system that exists between the business logic layer and the persistence / storage layer. A DAL might be a single class, or it might be composed of multiple Data Access Objects (DAOs). It may have a facade over the top for the business layer to talk to, hiding the complexity of the data access logic. It might be a third-party object-relational mapping tool (ORM) such as Hibernate.
DAL is an architectural term, DAOs are a design detail.
数据访问层将包含许多数据访问对象。
它的主要作用是将业务逻辑与数据库逻辑和实现分离。
例如,DAL 可能有一种方法,可以通过一个或多个数据访问对象从多个表、查询或存储过程中检索数据。
对数据库结构、DAO、存储过程甚至数据库类型的更改不应引起业务逻辑的更改,这取决于 DAL 提供的解耦。
A data access layer will contain many data access objects.
It's primary role is to decouple the business logic from the database logic and implementation.
For example the DAL may have a single method that will retrieve data from several tables, queries or stored procedures via one or more data access objects.
Changes to the database structure, DAOs, stored procedures or even database type should not incur changes to the business logic and this is down to the decoupling provided by the DAL.