vizcaine (7) [Avatar] Offline
#1
Hi, I was just reading Chapter 8 "Writing Hibernate Applications", and I have some comments on the part of "Rethinking data transfer objects"
I think the authors have overlooked a very important feature of this pattern.
First of all, the pattern is called "data transfer" for a reason, it's not supposed to represent an entity, or business concept, it's sole purpose is to transfer data between tiers.
When used in the presentation tier, this pattern can function as a "View Helper", to show search results to the user for example.
Now, let's say that in my results table I need property data, from 3 different entities or business objects. My table has 5 columns. If I were to do as the authors recommend, I would need 3 objects with a whole bunch of properties that I wouldnt even need.
If I use the Data Transfer Object as a View Helper, I could populate the object with only the 5 properties I need, and save myself the trouble of returning business entities to my web tier.
I don't think we should discard DTO's, and I totally disagree with the perspective that the authors have of the pattern.