What's the difference between DAO and Data Mapper
Asked Answered
C

1

5

Is there a difference between the DAO pattern and the Data Mapper pattern? Is DAO just one of doing Data Mapper?

Corneliacornelian answered 29/1, 2009 at 15:6 Comment(1)
Could you tag this "patterns" too?Alkyd
A
8

I wouldn't actually call DAO a "pattern". As I see it, DAO is pretty much what it is -- a Data Access Object", which encapsulates the details of accessing a persistent data store and generally speaking has nothing to do with the database:

interface IBlogDaoService
{
    Blog GetBlog(long id);
    void SaveBlog(Blog blog);
}

It's clear that implementations can use either DB (in which case it's quite logical to use a Data Mapper), or simple XML file storage mechanism.

The Data Mapper on the other hand is more of a pattern, which defines a layer responsible for translating in-memory graphs of objects to the relational structure.

Australasia answered 29/1, 2009 at 15:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.