What is the difference between DAO and DAL?

天涯浪子 提交于 2019-12-18 10:05:23

问题


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?


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/1086521/what-is-the-difference-between-dao-and-dal

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!