This week's book giveaway is in the Java 9 forum.
We're giving away four copies of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications and have Sander Mak & Paul Bakker on-line!
See this thread for details.
Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Transfer Objects(TO)  RSS feed

 
Dini Bang
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anyone have idea, on what basis the transfer objects for the application should be designed?
And how then can be light weighted and efficiently used.
 
Vinay Raj
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One reason why one would use a TO is if the application uses remote invocations. To reduce chattiness over the network, multiple method calls are wrapped around a single method and all information/data required is sent to the method via a single TO.

The second reason would be to define a crisp interface. Method invocations can be remote or local, however we want to clearly define the method to be invoked to achieve a given functionality. E.g. we can define a insurance Quoting Engine in two ways. One have setters for each of the parameter like age, face amount, gender etc on the Quoting engine or define a single TO encapsulating all the required attributes. Advantage is that addition of a new attribute/property does not affect the interface signature.
 
Dini Bang
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for the response...
But I am majorly concerned about three things :
1. Will constructing TO's with multiple level of abstartion(i mean implements, extends etc ) improve the performace , like the way over distributed system, will it help anyway?
2. How good is the idea of having TO of primitive data types over primitive data type objects
3. How can performace be boosted which To's used as setter/getter at database level, to transfer them from server to client n vice-versa. Esp in case of EJB's ?
 
shankar sawant
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well let me try to answer your questions to best of my knowledge and understanding of the questions..

Will constructing TO's with multiple level of abstraction(i mean implements, extends etc ) improve the performance , like the way over distributed system, will it help anyway?

-- Yes. It is better performance wise. Since you are building something called "Transfer Object Assembler" or composite TO, network traffic will reduce further and hence better performance. also Since you have design the TOs such that you send true or close to true network model back to client.
See "http://java.sun.com/blueprints/corej2eepatterns/Patterns/TransferObjectAssembler.html"

2. How good is the idea of having TO of primitive data types over primitive data type objects

-- I think objects will be better as we can program to it if necessary.

3. How can performance be boosted which To's used as setter/getter at database level, to transfer them from server to client n vice-versa. Esp in case of EJB's ?

-- I did not get this question but I think if your question is "Is TO good for distributed env." I would say "Yes"
 
Vinay Raj
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Replies to your questions:

I believe in your first question you are enquiring if developing object hierarchy in the TO will have a performance impact. To a certain extent it will. While passing over the wire more information regarding the object structure/hierarchy would be required. However if the object hierarchy is necessary, I would not be too worried about the impact unless you have deep object hierarchy.

Primitive data types consume less memory, hence would consume lesser number of bytes while sending them across the wire. I recommend you use them wherever possible.

Using TO is always a good idea and will definitely boost performance.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!