• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Data Transfer Object

 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
We can use a Data Transfer Object to transfer data between tiers as a big object which contains multiple attributes.
I was wondering what effect this has on the performance.
Is there a difference in duration between:
A) Marshalling/unmarshalling each attribute seperate.
b) Marshalling/unmarshalling the DTO.
Does someone knows this?
Thank you,
Roul
 
roul ravashimka
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think that A is the slowest, because for each attribute that needs to be
marshalled, there is a bytestream opened and closed.
B is the fastest, because only one bytestream is initialised.
Is this correct?
Thx,
Roul
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In general it is best to move the data as a single object rather than serialize it member by member. As you say, the overhead of creating several byte streams to handle the various members outweighs the cost of moving a lot of data across one stream. Also, it is in general better to use the functionality provided by the Java API rather than implementing your own (your code will be easier to write, read and maintain).
If you find you need to move a large number of these data objects, for listing purposes for instance, it is a common performance improvement to have two different objects. One with a few small fields for lists and another with the entire data set for editing.
 
reply
    Bookmark Topic Watch Topic
  • New Topic