Search the web
Sign In
New User? Sign Up
domaindrivendesign · Domain-Driven Design
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want to share photos of your group with the world? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
DDD Without any ORM tool, is it possible !!   Topic List   < Prev Topic  |  Next Topic >
Reply | Forward < Prev Message  | 
Hi All,

When reading DDD book and trying out it on a sample project that doesn't use any ORM tool. I came across a question,  is it possible to strictly implement DDD without any ORM tool !!
Is there any one here who has implemented DDD on any real project that doesn't use any ORM but pure JDBC only?

Before few days, I had a question on how to paginate and lazy load non root objects http://tech.groups.yahoo.com/group/domaindrivendesign/message/15925
Various alternatives and answers came up.. but why do I need to find an alternative..
I don't need to do any thing specific when using hibernate and just depend on the lazy loading support provided by it.

I want to paginate because I dont want to load entire graph of few thousand objects into memory and when using hibernate and lazy loading that's not an issue.
With NO -ORM, I can achive similar thing by using dynamic proxies for lazy loading.. and let repositories handle it..

However the second point is more important.

The second question is related to repositories, transitive persistence and dirty checking.

The DDD book (Chapter 6 - repositories) says "it allows freely switching persistence strategies at any time." 

is it really possible without modifying domain at all !!

How about dirty checking without any ORM ?
When you save/update an aggregate root, entire graph should be saved and/or updated. How the repository will determine which objects are modified/inserted or deleted?
Probably you will need some thing like isNew() isStale() inside every entities to find out if it needs to be included as part of insert/update. And set flags when ever any setter or any other method changes state of the object. I have seen similar thing in a project which uses DDD with JDBC.

These things are not required when using hibernate.

How about Delete?
Lets say root has collection of associated entities (In my example MessageFolder has Collection of messages)

I can do some thing like

MessageFolder.remove(Message message) 

that would remove message from the collection. When saving the MessageFolder, how the repository can find out what messages are deleted?
Either message folder need to maintain a collection of removed messages or repository need to have old message folder for comparision.
the first option forces me to modify MessageFolder, that mean domain model became aware of underlying persistence technology. The second option would need to load old entity which would affect performance.

It might be possible to switch to ORM from a NO - ORM application but what about switching to NO - ORM from ORM !! does that mean I will have to add custom behaviour to my entities to figure out weather they are new or modified or deleted.

These are few questions that I am not able to answer my self and seeking some expert thoughts.

Pardon me for my poor english and understandign of DDD concepts.

Thanks
Sudhir






Tue Nov 10, 2009 10:46 am

sania_with_u
Online Now Online Now
Send Email Send Email

Forward
< Prev Message  | 
Expand Messages Author Sort by Date

Hi All, When reading DDD book and trying out it on a sample project that doesn't use any ORM tool. I came across a question, *is it possible to strictly ...
Sudhir Ramanandi
sania_with_u
Online Now Send Email
Nov 10, 2009
10:46 am

Yes, it is possible.   Short answer: If the ORM can do it it can surely be hand coded.   Long answer: this is what you normally would have to hand code...
Fredrik Klintebäck
fklinteback
Offline Send Email
Nov 10, 2009
11:15 am

On Tue, Nov 10, 2009 at 4:44 PM, Fredrik Klintebäck ... case there could be more too.. how about performance - That says, write some thing like your own...
Sudhir Ramanandi
sania_with_u
Online Now Send Email
Nov 10, 2009
11:33 am

DDD is for your business domain. How you solve the 3/4 that doesn't fit into that part of your solution really isn't a DDD issue. ORM or NoORM is a...
Torbjörn Gyllebring
torbjorn.gyl...
Offline Send Email
Nov 12, 2009
8:27 pm

look at martin fowler's book patterns of enterprise application architecture and read the chapter/section on "unit of work". That is the pattern that you use...
Justin Daubenmire
JDaubenm
Offline Send Email
Nov 10, 2009
11:46 am

You could check out my example on CQRS, which is a DDD implementation that is not using a real ORM. I left it out for simplicity and because that is not where...
Mark Nijhof
mark.nijhof
Offline Send Email
Nov 10, 2009
11:53 am

Sure.. I would like to look at the examples. ... - I wanted to write this in my first message "Don't ask me why I don't want to use any ORM". This isn't...
Sudhir Ramanandi
sania_with_u
Online Now Send Email
Nov 10, 2009
12:09 pm

I meant without any costs that involves your domain, sure you have to implement your own persistence or adapt to use a different ORM, but these things should...
Mark Nijhof
mark.nijhof
Offline Send Email
Nov 10, 2009
12:52 pm

I absolutely agree that, in principle, you should be able to implement your domain objects without any knowledge of the underlying persistence technology. But...
Jorn Wildt
jorn_lind_ni...
Offline Send Email
Nov 10, 2009
1:09 pm

Agreed, but by using proper abstraction as we did when using Active Record and still using a repository to call Save on the Entity itself you are making a...
Mark Nijhof
mark.nijhof
Offline Send Email
Nov 10, 2009
1:25 pm

Jørn captures an important benefit implied by Repository pattern. Since Repository mimics a Collection, when you update an object already contained in the...
vvernon_shiftmethod
vvernon_shif...
Offline Send Email
Nov 10, 2009
4:09 pm

Just a note on collections. The are multiple types of collections (Sets, Lists, Bags, Sets, Trees, Graphs, Queue etc etc etc). In the data structure domain...
Nuno Lopes
nbplopes
Offline Send Email
Nov 10, 2009
6:15 pm

Hello Sudhir, I don't use an ORM. Each entity that requires global access gets a Repository. I then have a Mapper for the entity --- a little factory to create...
eben_roux
Offline Send Email
Nov 11, 2009
6:49 am

Its good to know that you are using DDD with No ORM.. Can you tell me, how repositories handle modification to aggregate roots? As said in my first message,...
Sudhir Ramanandi
sania_with_u
Online Now Send Email
Nov 11, 2009
7:11 am

Hello again, I use Domain Events to pick up the changes. SO if something changes in the 'AR' that I am interested in I raise the domain event, e.g. OrderAdded....
eben_roux
Offline Send Email
Nov 11, 2009
7:56 am

Thanks, Got it now.. No dint know about Udi's blog... Will have a look. Thanks...
Sudhir Ramanandi
sania_with_u
Online Now Send Email
Nov 11, 2009
9:16 am

This may not be the best routine, but I use a boolean flag to determine what needs persisted. I have a property in each entity called .IsDirty. When anything...
Justin Daubenmire
JDaubenm
Offline Send Email
Nov 11, 2009
12:16 pm

... From: Torbjörn Gyllebring DDD is for your business domain. How you solve the 3/4 that doesn't fit into that part of your solution really isn't a DDD...
Justin Daubenmire
JDaubenm
Offline Send Email
Nov 12, 2009
11:47 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help