----- Original Message -----
From: "Michael Hart" <
michael.hart.au <at> gmail.com>
To: <
domaindrivendesign <at> yahoogroups.com>
Sent: Tuesday, March 31, 2009 10:36 PM
Subject: Re: [domaindrivendesign] ORM and DDD layers
> Hi Justin,
>
> First up, I'd say to read up on Repositories - you mention them in
> passing in your post, but that's really where the action happens
> between your domain and infrastructure, so make sure you're fully
> clued in with them.
>
> Secondly, there are two basic ways you can go with an ORM in DDD:
>
> 1. Use the objects that your ORM instantiates as your domain objects
> (and design them as such)
> 2. Map between your ORM objects and your domain objects
>
> Option 1 is the most common I've seen, but it usually imposes certain
> restrictions on how you can shape your domain and instantiate your
> objects. Different ORMs will give you different amounts of pain in
> this regard.
>
> Option 2 gives you full control over the shape and lifecycle of your
> domain objects (including instantiation), but you will need to write
> more glue code, especially if you need some features that you get for
> free with an ORM, such as lazy loading and automatic unit-of-work
> management. This option is not too removed from the examples you
> describe, although there'd be less/no SQL.
>
> So, if you want to keep your domain as pure as possible, or you're
> stuck with an especially nasty DB schema, go with Option 2 - if you
> want the pragmatic, and hopefully quicker approach, go with Option 1.
>
> That'd be my two cents anyway.
>
> Cheers,
>
> Michael
>
> On 01/04/2009, at 12:05 PM, Justin Daubenmire wrote:
>
>> All,
>>
>> Me and my programming team are using DDD on our first project. So
>> far it has
>> been very exciting to all of us. There are four of us on the team.
>>
>> We have hit a point of discussion that none of us can seem to figure
>> out. So
>> I figured I'd come ask the experts!
>>
>> We are using Microsoft .NET for the development of this project, I
>> know DDD
>> really isn't technology specific, but I wanted to let everyone know
>> what we
>> are using in case others have hit this point too.
>>
>> We are using the Microsoft entity framework for our
>> infrastructure.database
>> layer. Our choices are nhibernate or the Microsoft entity framework.
>>
>> The problem we are having is understanding how the entity framework
>> and
>> domain layer work together in DDD.
>>
>> The entity framework returns entities that are I guess domain layer
>> objects
>> related directly to a table in the database and are already
>> populated with
>> data.
>>
>> In our research, we have seen things such as the
>> infrastructure.dataaccess
>> layer being sql that is executed against the database for the data
>> and in
>> turn, the infrastructure layer requests a domain entity from the
>> domain
>> layer. The infrastructure layer then creates the domain entity and
>> populates
>> it with data from the database. The infrastructure layer then
>> returns the
>> inflated domain object to the caller which could be a repository or
>> service
>> layer.
>>
>> So, how does the entity framework fit into this mold? The entity
>> framework
>> has entities already instantiated and all data mapped in them from the
>> database directly at the infrastructure.dataaccess layer and never
>> needs the
>> domain layer to get a domain layer entity.
>>
>> Some questions we are pondering....
>>
>> If the entity framework in the infrastructure layer is getting the
>> data and
>> inflating the entity for us, then how do we use domain objects?
>> Entities are
>> in the domain but the entity framework has seemed to combine the
>> concept of
>> a domain entity and the database together.
>>
>> Can someone please help me understand how to use entity framework in
>> DDD?
>> Perhaps the entity framework is not a good orm to use? I know that
>> there is
>> nhibernat for .net and hibernate for java. Are those more suited for
>> DDD
>> rather than the entity framework?
>>
>> Thanks to everyone for any opinion, feedback, and help... all of it
>> welcomed
>> and appreciated!
>>
>> /Justin
>>
>>
>>
>> ------------------------------------
>>
>> Yahoo! Groups Links
>>
>>
>>
>
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>
>
>