views:

922

answers:

3

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?

+2  A: 

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.

ChrisBD
A: 

I would say they have similarities. However, the DAL could be considered as your DAO factory.

You could have a list of DAO's that represent objects in your database i.e. IDBCustomer, IDBPerson which does the database interaction (of that one object) only. Then you could have your DAL which can have methods like GetCustomers() which returns you a list of IDBCustomers.

So I suppose they can be considered differently, however, in most cases I think you'll find they work in conjunction.

James
+9  A: 

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.

Matt Howells
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?
Kuytu
That sounds right to me.
Matt Howells