Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Data Transfer Object  RSS feed

 
roul ravashimka
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Joe Ess
Bartender
Posts: 9428
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • 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.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!