kaushik_spock | 1 Jun 07:25
Picon

Re: How it all fits together

> Is the domain layer supposed to define persistence in the structure of its entities according to DDD design as demanded by hibernate?

In a way defining annotations on your entities bring persistence awareness to your DDD entities. However it still does not assume responsibility for the actual persistence. The actual persistence would still be handled outside the domain layer. So no pollution of domain entities happen imho.

Practically,  I actually like having annotations in code compared to an external hbm file since i can see/understand the persistence structure when looking at code. This is quite handy when looking at new code and trying to figure out the behaviour.


> 3. Is the service layer a part of the domain layer?

If you mean service la yer then they are not part of domain. But if you mean services themselves the domain layer can have services within them. I have blogged  about domain services recently and have covered this question where i have pointed to a few links where this  has been discussed in great detail. Have a look.

Thanks,
Kaushik
http://stochastyk.blogspot.com/


--- In domaindrivendesign <at> yahoogroups.com, "dover.roni" <roni.dover <at> ...> wrote:
>
>
> I have been reading about DDD but seem to be having problems
> understanding how it falls into place with other concepts I'm familiar
> with. For examp le:
>
> 1. DAO objects (CRUD), should they be a part of the domain model for
> each entity? How do they fit in with the big picture here?
>
> 2. I'm using hibernate and have mapped my domain classes using
> annotations, is that bad form because it brings persistence logic into
> the domain layer? Is the domain layer supposed to define persistence
> in the structure of its entities according to DDD design as demanded
> by hibernate?
>
> 3. Is the service layer a part of the domain layer?
>
> Thanks in advance,
>
> Roni
>
__._,_.___

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___
coc.kiest | 1 Jun 07:40
Picon
Favicon

Re: Database transaction of the Repository?


I just walked through the code in SmartCA. What confuse me is the 
IRepository more like a IDataMapper, which is sit in the 
Infrastructure/Persistence layer & without the Matching(ICriteria 
criteria) method. Besides, its IEntity & IUnitOfWork also in the 
Infrastructure layer. It doesn't have clean separation between the 
domain and infrastructure. 
Is this the only pragmatic way of coding? Or I have missed something? 
Thank you.

--- In domaindrivendesign <at> yahoogroups.com, "Dicky Arinal" 
<dicky.arinal@...> wrote:
>
> On Wed, May 28, 2008 at 11:26 PM, coc.kiest <coc.kiest@...> wrote:
> > Hi geeks,
> >
> > Is it appropriate to pass database transaction across different
> > repository objects?
> Yup, you will gonna need Unit of Work pattern [fowler].
> 
> I usually give a parameter for unit of work in the repositoriy
> constructor like this:
> 
> IUnitOfWork unitOfWork = new UnitOfWork();
> 
> IEmployeeRepository employeeRepo =
> RepositoryFactory.Create<IEmployeeRepository, Employee>(unitOfWork);
> 
> and some where beneath the factory function:
> 
> RepositoryFactory.Create<TRepository, TEntity>(IUnitOfWork 
unitOfWork) {
> .
>     return new EmployeeRepository(unitOfWork);
> .
> }
> 
> My UnitOfWork actually doesn't know how to manipulate the database, 
it
> just commit the appending transaciton.
> 
> If you wanna full source code for this kind of solution, maybe you 
can
> find Tim McCarthy's SmartCA at Code Plex.
> 
> regards,
> 
> Dicky Arinal
> Developer @ Transavia Indonesia
>

------------------------------------

Tomas Karlsson | 1 Jun 12:32
Picon

SV: How it all fits together

 
I strongly recommend annotations of the Domain objects as the persistence mechanism. OK, there will be a connection between the pure domain and the persistent storage of the object. But in real life, how often do you change persistence mechanism in a project. Keeping everyting in the same source code file (and avoid the hbm.xml files) is a higher value than a strict application of DDD in its purest form.
 
/Tomas

Från: domaindrivendesign <at> yahoogroups.com [mailto:domaindrivendesign <at> yahoogroups.com] För dover.roni
Skickat: den 31 maj 2008 06:59
Till: domaindrivendesign <at> yahoogroups.com
Ämne: [domaindrivendesign] How it all fits together


I have been reading about DDD but seem to be having problems
understanding how it falls into place with other concepts I'm familiar
with. For example:

1. DAO objects (CRUD), should they be a part of the domain model for
each entity? How do they fit in with the big picture here?

2. I'm using hibernate and have mapped my domain classes using
annotations, is that bad form because it brings persistence logic into
the domain layer? Is the domain layer supposed to define persistence
in the structure of its entities according to DDD design as demanded
by hibernate?

3. Is the service layer a part of the domain layer?

Thanks in advance,

Roni

__._,_.___

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___
Rickard Öberg | 1 Jun 12:43
Picon
Gravatar

Re: SV: How it all fits together

Tomas Karlsson wrote:
> I strongly recommend annotations of the Domain objects as the 
> persistence mechanism. OK, there will be a connection between the pure 
> domain and the persistent storage of the object. But in real life, how 
> often do you change persistence mechanism in a project. Keeping 
> everyting in the same source code file (and avoid the hbm.xml files) is 
> a higher value than a strict application of DDD in its purest form.

One question is, where do you draw the line when it comes to domain 
object metadata. For example, where do you put the labels to be shown in 
forms for a fields. Also in an annotation? What if it needs to be in 
many languages? Icon references? These kinds of things might be better 
to keep outside of the code, in Resource Bundles (if we're talking 
Java). But then, if you have that, would it then make sense to also have 
persistence mappings in Resource Bundles so as to have all metadata in 
one place?

/Rickard

------------------------------------

dover.roni | 1 Jun 23:12
Picon
Gravatar

Re: How it all fits together


Thank you all for you insights.

I'm still considering the DAO though, I implemented the generic DAO as
illustrated by Java Persistence With Hibernate, and it seems to
combine CRUD operation with persistence operations (Persist, Make
Transient). Maybe thats the separation. 

However, even if the pure dao operations belong with the domain logic,
where do they fit in? Should the "Employee" entity have a static
"FindByID" method?

Still confused but getting there..

------------------------------------

Tim McCarthy | 2 Jun 03:42
Picon
Favicon

Re: Database transaction of the Repository?

I speficially did not put in a Matching(ICriteria criteria) method in my IRepository interface.  Instead, I allow for the interface to be extended in the Domain Model, such as IProjectRepository : IRepository<Project>.  This way, you can do whatever you want in IProjectRepository, but you still get some things for free from the Infrastructure layer (i.e. IRepository<T> and RepositoryBase<T>.

I think putting IEntity and IUnitOfWork in the Infrastructure layer actually gives me more freedom...you have to remember that Infrastructure is not just about persistence, it's really about any type of "plumbing" code that you have.  Since some of the classes in the Infrastructure layer need to know about IEntity and IUnitOfWork, I went ahead and put them there, otherwise there would be circular references between the Infrastructure and the Domain Model.  As it stands now the DOmain Model references the Infrastructure, which is how I think it should be.

For more information on these design choices please read my book that details the SmartCA application:

http://www.amazon.com/dp/0470147563?tag=timcsbl-20&camp=14573&creative=327641&linkCode=as1&creativeASIN=0470147563&adid=1PM1GEM10EJRF3EXRAES&

Thanks,

Tim

--- In domaindrivendesign <at> yahoogroups.com, "coc.kiest" <coc.kiest <at> ...> wrote:
>
>
> I just walked through the code in SmartCA. What confuse me is the
> IRepository more like a IDataMapper, which is sit in the
> Infrastructure/Persistence layer & without the Matching(ICriteria
> criteria) method. Besides, its IEntity & IUnitOfWork also in the
> Infrastructure layer. It doesn't have clean separation between the
> domain and infrastructure.
> Is this the only pragmatic way of coding? Or I have missed something?
> Thank you.
>
>
>
> --- In domaindrivendesign <at> yahoogroups.com, "Dicky Arinal"
> dicky.arinal <at> wrote:
> & gt;
> > On Wed, May 28, 2008 at 11:26 PM, coc.kiest coc.kiest <at> wrote:
> > > Hi geeks,
> > >
> > > Is it appropriate to pass database transaction across different
> > > repository objects?
> > Yup, you will gonna need Unit of Work pattern [fowler].
> >
> > I usually give a parameter for unit of work in the repositoriy
> > constructor like this:
> >
> > IUnitOfWork unitOfWork = new UnitOfWork();
> >
> > IEmployeeRepository employeeRepo =
> > RepositoryFactory.Create<IEmployeeRepository, Employee>(unitOfWork);
> >
> > and some where beneath the factory function:
> >
> > RepositoryFactory.Create<TRepository , TEntity>(IUnitOfWork
> unitOfWork) {
> > .
> > return new EmployeeRepository(unitOfWork);
> > .
> > }
> >
> > My UnitOfWork actually doesn't know how to manipulate the database,
> it
> > just commit the appending transaciton.
> >
> > If you wanna full source code for this kind of solution, maybe you
> can
> > find Tim McCarthy's SmartCA at Code Plex.
> >
> > regards,
> >
> > Dicky Arinal
> > Developer <at> Transavia Indonesia
> >
>

__._,_.___

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___
Geoffrey Wiseman | 2 Jun 04:34
Picon
Gravatar

Re: SV: How it all fits together

On Sun, Jun 1, 2008 at 6:43 AM, Rickard Öberg <rickardoberg <at> gmail.com> wrote:
One question is, where do you draw the line when it comes to domain
object metadata. For example, where do you put the labels to be shown in
forms for a fields. Also in an annotation? What if it needs to be in
many languages? Icon references? These kinds of things might be better
to keep outside of the code, in Resource Bundles (if we're talking
Java). But then, if you have that, would it then make sense to also have
persistence mappings in Resource Bundles so as to have all metadata in
one place?

It's this sort of thing that keeps me using the external Hibernate XML files.  I just find it clutters the domain class, and I worry that I'll eventually end up with so much metadata that I can't see the domain class.

That said, I will note that with Hibernate in particular, the annotation style does serve you well when you get into inheritance.

   - Geoffrey
--
Geoffrey Wiseman
__._,_.___

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___
randy.stafford | 2 Jun 05:54
Picon
Favicon

RE: SV: How it all fits together

Geoffrey Wiseman wrote:

 

It's this sort of thing that keeps me using the external Hibernate XML files.  I just find it clutters the domain class, and I worry that I'll eventually end up with so much metadata that I can't see the domain class.

 

Exactly.  I too prefer the separation of concerns achieved by keeping O/R mapping metadata separate.  When I look at domain model code, that’s what I want to see: domain model code.  The literate programming idea implemented by javadoc is great, but somewhere along the line, with xdoclet and JSRs 175 and 220, things got out of control.  I imagine there are probably some great uses of annotations to include metadata that is highly cohesive with the domain model but, as Rickard asked, where do you draw the line?  One place I’d draw it is between domain model and persistence; those are separate concerns.

 

Kind Regards,

Randy Stafford

http://c2.com/cgi/wiki?RandyStafford

 



__._,_.___

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___
Rickard Öberg | 2 Jun 07:43
Picon
Gravatar

Re: SV: How it all fits together

randy.stafford <at> oracle.com wrote:
> Exactly.  I too prefer the separation of concerns achieved by keeping 
> O/R mapping metadata separate.  When I look at domain model code, that’s 
> what I want to see: domain model code.  The literate programming idea 
> implemented by javadoc is great, but somewhere along the line, with 
> xdoclet and JSRs 175 and 220, things got out of control.  I imagine 
> there are probably some great uses of annotations to include metadata 
> that is highly cohesive with the domain model but, as Rickard asked, 
> where do you draw the line?  One place I’d draw it is between domain 
> model and persistence; those are separate concerns.

I should add that I often begin my lectures by saying sorry for XDoclet 
:-) It seemed like a good idea at the time, but now it more seems like a 
workaround for bad design patterns... oh well..

Anyway, it seems to me that this lack of a unified way to do metadata, 
and to consider the different phases (development, packaging, 
deployment, production, etc.), is something that is forcing us to do all 
sorts of workarounds, including annotations. There's gotta be a better way.

/Rickard

------------------------------------

Aeden Jameson | 2 Jun 08:53
Picon

Spring in the Context of DDD

Hi,

    I've been exploring Spring.net recently and one thing that sticks
out to me is the call to GetObject().  It got wondering, are people in
practice using spring within the domain? Are folks putting these calls
in their domain objects, in the factories of their domain objects? Perhaps
Spring is best used to wire together layers? (e.g. wire up services in
your controller or page)
What's your opionon on the role of spring within a DDD project?

--

-- 
Cheers,
Aeden

------------------------------------


Gmane