Is it a good idea for a DTO to have another DTO - design-wise or are there any pitfalls to this?
for example,
EmpID_DTO {
String id1;
String id1;
// other ID related fields .....
// .....
}
EmpDTO{
String Name;
Date DOB;
EmpID_DTO IDs;
// other ID related fields .....
// .....
}
-PI
-
DTO having another DTO (3 messages)
- Posted by: P I
- Posted on: March 10 2005 11:24 EST
Threaded Messages (3)
- DTO having another DTO by Paul Morie on March 10 2005 12:38 EST
- DTO having another DTO by Aaron Craven on March 10 2005 21:08 EST
- thanks by P I on March 11 2005 11:37 EST
-
DTO having another DTO[ Go to top ]
- Posted by: Paul Morie
- Posted on: March 10 2005 12:38 EST
- in response to P I
Hi P-
I employ a heirarchical DTO structure in a project I'm working on now. My only suggestion is to beware of cyclical relationships. Remember, the point is to present coarse-grained views of finely grained data. In short, I think it's ok.
HTH,
P -
DTO having another DTO[ Go to top ]
- Posted by: Aaron Craven
- Posted on: March 10 2005 21:08 EST
- in response to P I
I am also using a similar pattern in my project. In my case, each DTO has a Collection of other DTOs. When calling my EJB "getter" for the "root" object in this hierarchy, I indicate whether or not I want these Collections populated.
Obviously, I would prefer to lazy load these collections, but I was unable to come up with an appropriate way to do this and still maintain the spirit of the TransferObject design pattern -- it rather defeats the purpose if my data transfer object needs to access live model data to do its job.
See this thread for more information on my situation: http://www.theserverside.com/discussions/thread.tss?thread_id=32284 -
thanks[ Go to top ]
- Posted by: P I
- Posted on: March 11 2005 11:37 EST
- in response to P I
Thanx for your replies.
-PI