-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 15 posts ] 
Author Message
 Post subject: what's the meaning of DTO???
PostPosted: Mon Dec 01, 2003 1:42 am 
Beginner
Beginner

Joined: Sat Nov 01, 2003 6:14 am
Posts: 30
i saw it in the HibernateJAOO ppt

i can't exatly understand the meaning of this section:

Code:
DTOs are Evil

“Useless” extra LOC
Not objects (no behavior)
Parallel class hierarchies smell
Shotgun change smell


what's the meaning of DTOs?

and how is LOC?

any help is high appreciated!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 01, 2003 2:33 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Data Transfer Object
Lines Of Code


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 01, 2003 2:59 am 
Beginner
Beginner

Joined: Sat Nov 01, 2003 6:14 am
Posts: 30
thanks , gavin

i am building a ppt to introduct Hbernate to my company.

i wanna more people to enjoy the Hibernate World!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 01, 2003 7:37 pm 
Pro
Pro

Joined: Tue Aug 26, 2003 8:07 pm
Posts: 229
Location: Brisbane, Australia
What's the alternative to DTOs if you don't want to expose your domain objects, detached or not, to your presentation layers?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 01, 2003 7:51 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Nothing. DTO is a (partial/ aggregate) copy of your domain model.
Your domain model is what you need to think about. So opening it as a public API seems quite good to me. Most time, domain model updates will update DTO (or whatever you call them)

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 01, 2003 7:51 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Why do you not want to expose your domain objects to the presentation layer? You don't like object orientation?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 01, 2003 7:58 pm 
Pro
Pro

Joined: Tue Aug 26, 2003 8:07 pm
Posts: 229
Location: Brisbane, Australia
I subscribe to the (IMO extremely sound) principle of architectural serparation of the major layers within an application, therefore I must not like object orientation?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 01, 2003 8:02 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I did think as you did, but as a developper, I was sick of rewriting my domain model to a new DTO domain model for almost nothing.
I know it envolve agile devt and this not so accepted, but in real life it's quite convinient (IMO).

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 01, 2003 8:03 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Quote:
I subscribe to the (IMO extremely sound) principle of architectural serparation of the major layers within an application


Soundness is in the eye of the beholder.

Let me ask you a question: do you actually achieve any real seperation here? Or do you really just achieve code duplication?

Is it really the case that your presentation layer does not change when you change your domain model?? I have never ever seen a single practical case where I made a change to my domain model that did not also involve some change in my presentation layer. All the extra DTO layer meant was that I had to change in three places instead of only two. This is what Fowler calls the "shotgun change" code smell.

Quote:
therefore I must not like object orientation?


Sounds like it. DTOs are not objects (state + behavior).


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 01, 2003 8:46 pm 
Pro
Pro

Joined: Tue Aug 26, 2003 8:07 pm
Posts: 229
Location: Brisbane, Australia
Hmmmmm, quoting from Fowler to back up one's arguments. Sounds like fun - let me try:

Quote:
Furthermore, each layer usually hides its lower layers from the layers above, so layer 4 uses the services of layer 3, which uses the services of layer 2, but layer 4 is unaware of layer 2. (Not all layering architectures are opaque like this, but most are - or rather most are mostly opaque.

Chapter 1 - "Layering", 2nd paragraph, page 17.
Patterns of Enterprise Application Architecture (written & published much more recently than the refactoring book)


Now seriously, in the words of another wise man, I don't want this to degenerate into a pissing contest.

In part at least, I do agree with you. We do actually achieve some real separation, but it's really hard it's imperfect at best and it does suffer from all the problems you've mentioned. To be honest, I've been asking myself some hard questions about the real value of strictly enforcing separation of the application layers this way, and I actually am pretty sure it's not worth the level of effort it takes.

But on the other hand, I don't know what else to do.
Layering sounds like a good idea, it's just that enforcing the separation of layers (which is the whole point) just turns out to be too hard. But is the answer really to just throw away the concept and say "it's too hard, so we'll just let the domain model propogate back up to the presentation layer, stop thinking about it and tell anyone who asks that they don't know squat about real object orientation"?


Quote:
Is it really the case that your presentation layer does not change when you change your domain model??

Actually, yes, for small changes. We've created a concept we call Declarative DTOs, where the DTO is not only a packaging for the data, it is also a declaration of where in the domain model (given an arbitrary graph root) each attribute comes from. So when attributes move around, the DTO can actually track those movements. Of course, it only works for simple changes; but then if the domain model really drastically changes, the presentation layer will change too (uh-oh, sounds like a shotgun change, better refactor that domain model away from the GUI, eh?).
That said, our Declarative DTOs suck, thw whole concept sucks and I wouldn't recommend anyone even bother with the idea. But what else to do?

You said in your blog that Christian got very excited about CarrierWave a while ago - which kind of implies that he's not excited about it anymore? I looked at it and it seems like it might be a way forward, especially with a quote like this from their front page:
Quote:
It means that... Client and server side developers will have an architecturally enforced layer of isolation.
I'd really like to hear from Christian on this if he did any serious research int it?

Also, from your blog entry and on the dev mailing list, you've been talking about SDOs lately. Do you see them being useful for this kind of stuff, or are you looking at them from some other kind of perspective? (maybe looking at making Hibernate intergate as one of the datasources or something)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 01, 2003 9:01 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
CarrierWave is still very very interesting, because it addresses all the concerns discussed in this thread. The jury is still out if CarrierWave, SDO or any of the other approaches (some people even try to use XML, but I don't think its a good choice for various reasons) is the way to go.

I'm still making up my mind about this, in fact, I've been thinking about the decoupling of the UI tier for quite some time (a year?), but never had the patience to think it through.

Because I'm talking about this in my presentation at JavaPolis, I'm having a look at CarrierWave again right now. You can expect more on this subject in the next weeks, it's definitely at the top of my list. Oh, there is even a (messy) Wiki page I started some time ago:

http://www.hibernate.org/Documentation/ ... chitecture

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 01, 2003 9:02 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Quote:
stop thinking about it and tell anyone who asks that they don't know squat about real object orientation"?


Sorry, my comment wasn't meant in that way.

I just try to challenge people to think about things and not sign on to concepts like layering where they are not appropriate.

Overengineering is absolutely endemic in the J2EE community and is really starting to threaten the very existence of Java. Microsoft exploit this mercilessly at the moment.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 01, 2003 9:40 pm 
Pro
Pro

Joined: Tue Aug 26, 2003 8:07 pm
Posts: 229
Location: Brisbane, Australia
christian wrote:
Oh, there is even a (messy) Wiki page I started some time ago:
http://www.hibernate.org/Documentation/ ... chitecture


I know, you started it based on a topic request I posted :)
But it never turned into what I wanted, which was someone else to do all the thinking and then tell me how to solve the whole issue :\

Incidentally, will all the Hibernate team (including yourself) be having Hibernate related blogs?

Cheers,
Shorn.


Top
 Profile  
 
 Post subject: My ideal situation...
PostPosted: Tue Dec 02, 2003 12:25 pm 
Newbie

Joined: Wed Nov 26, 2003 3:03 pm
Posts: 9
Location: Denver, CO
Ideally I would be using my persisted object classes as my DTOs. They're really just beans, so the only issue I currently have is that Hibernate collections serialize to Hibernate collections, so either my clients need to have the hibernate jars (a pain), or I need to rebuild each object with a copied collection. On another thread someone discussed modifying the writeObject methods in the hibernate collections so that they write out a normal serializable collection. I don't know if this will break anything else, but it seems useful to me...

Derek


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 03, 2003 12:22 pm 
My 0.02c worth:

Back in the 'bad' old days of SQL client-server, the domain model was exported directly to the client/business layers via SQL visibility. This seems to have suffered from undue linkage between presentation, business, data model and database layers, for various reasons.

As hibernate objects are basically copies of the data model, we may be going back down the same route.

If we want to use a layered architecture, 'plumbing' as it is called seems a necessary evil. In many ways the DTO pattern provides an abstracted interface between layers which means that for large (or should that be very large :-( applications, changes to the data model to support NEW functionality can be implemented in the most effective manner while avoiding changes to application which access related entities.

I agree there is a lot of plumbing to do, but the ability to keep layers independant (of domain changes as well as technology and tools used) and retain pure-java relationships between objects (not to belittle Hibernate's collections) helps this.

Control over DTO's and serialisation also brings control over performance (especially for remote communications) back into the application.

I deplore the additional work, over-engineering, multi-point (shotgun) changes etc, so have been looking for alternatives.

The best approach seems to be a Model Driven Architecture (MDA) which was rich enough to generate all required entities, relationships etc. This is a complex (and generally expensive) beast.

To counter-argue my own case, such multi-architecture layer MDA system may as well re-introduce the linkage between layers as there would be almost no scope for manual work within the layers!

I think XDoclet or some other technique could be used to support this approach, but the generation of multiple versions of the DTOs may be needed as the domain model changes, and business layers can request a deprecated one unchanged if appropriate.


Top
  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 15 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.