All entries for Monday 03 October 2005

October 03, 2005

DAOs, love em or hate em, you just gotta have one

So without going into the whole "ORM shouldn't affect your design" coupled with the benefits of transparent persistence (or at least, semi-transparent) :), how do you deal with DAOs (Data Access Objects)?

Typically a DAO looks like:


  interface MyDAO {
    void save(User user);
    void save(BlogEntry entry);
    etc.
    User load(final User details);
    etc.
  }

This gets really tedious very quickly. It is also a bit naff from an OO point of view, try describing it's functionality without using the word "and" a lot :)

Another approach is to use a domain object specific DAO, i.e. a UserDAO and a BlogEntryDAO. This also really gets tedious very quickly.

A third approach, is to introduce an interface which all persistant objects implement, then your DAO has a single save(Persistant persistantObject) etc.

No idea which is the better approach to be honest, all of them suck.

To be honest, the concept of a DAO is quite sucky to start with :)

Thoughts/comments….


October 2005

Mo Tu We Th Fr Sa Su
Sep |  Today  | Nov
               1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31                  

Search this blog

Tags

Galleries

Most recent comments

  • Interesting… While I'm not completely convinced in such microbenchmarks, I'm pretty sure that 1ms … by Alexander Snaps on this entry
  • Hello. I bought the book yesterday. I was trying to find the source code for chapter 11 and chapter … by Suleman on this entry
  • http://woosight.net/account/login?username=demo by live mashup demo on this entry
  • Thanks mate ….. This blog was really helpful. by Maaz Hurzuk on this entry
  • Ty. Not directly helpful for my problem, but pointed me in the right direction. You will also get th… by Mike E. on this entry

Blog archive

Loading…
Not signed in
Sign in

Powered by BlogBuilder
© MMXXI