63

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
  • 1
    I always thought DAL as Data Abstraction Layer Jul 6, 2009 at 11:33

2 Answers 2

101

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
  • 4
    Let's say I have an interface called DAO that has a methods like getCustomer(). The interface is implemented by SqlServerDAO-class. When getCustomer() is called the SqlServerDAO fetches the data from DB, creates and returns Customer-object. In this case the DAL consists of DAO-interface and SqlServerDAO-class, right?
    – simoraman
    Jul 7, 2009 at 5:54
  • 17
    +1 for "DAL is an architectural term, DAOs are a design detail." Apr 12, 2013 at 18:02
20

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.