1. Did any of you used one class for Domain and DTO? Is Yes, advantages and disadvantages.
DTOs are called Data Transfer Objects because their whole purpose is to shift data in expensive remote calls. They are part of implementing a coarse grained interface which a remote interface needs for performance. Not just do you not need them in a local context, they are actually harmful both because a coarse-grained API is more difficult to use and because you have to do all the work moving data from your domain or data source layer into the DTOs.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
SCJP5 | SCBCD5 | SCEA5 Part 1
Originally posted by Beno�t de CHATEAUVIEUX:
Since JPA, Hibernate, Toplink and other ORM Frameworks, you can define your Domain Model with POJOs.
In this case, does-it make sense to add a DTO layer ?
I mean you can share those POJO entities with the presentation tier...
The only problem I can see deals with Lazy Loading.
As lazy loaded collections are implementations of the Collection interface specifics to the ORM framework, you need to have the ORM framework libraries in your presentation tier.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
You can't wake a person who is <b><i>pretending</i></b> to be asleep.<br />Like what <b>"it"</b> does not like - <i> Gurdjieff </i>
At least with hibernate, the lazy loading collections implement the java.util interfaces, so even the POJOs don't need to know about them, let alone the presentation layer.
SCJP5 | SCBCD5 | SCEA5 Part 1
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Before software can be reusable, it first has to be usable. - Ralph Johnson
Originally posted by Nachiket Patel:
I am having query that, at j2se client, i received entity [POJO] say Department, which contains list of Employee entity [POJO]. So when i get department client side, actual employee list will not be there, but stub[proxy] will be there, and when i'll call getEmployee() or something on department, then employee list will be fetched?
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
SCJP, SCWCD, SCBCD, SCEA 5
Originally posted by Jonathan Aotearoa:
DTO also facilitates loose coupling between the presentation and business tiers, which is not to be sniffed at.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
SCJP, SCWCD, SCBCD, SCEA 5
Originally posted by Jonathan Aotearoa:
The Interface Segregation principle also suggests that some properties won't be exposed to the presentation tier, in which case why incur unnecessary network overhead by sending them?
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |