Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Transfer Object pattern

 
Parth Twari
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which two are benefits of the Transfer Object pattern? (Choose two.)

A.It hides access to entity beans

B.It reduces network latency problems.

C.It encapsulates access to a database table into one object.

D.It provides a single point of access to retrieve remote EJBs.

Source: SAI

What's your take?
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2277
81
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you think is the correct answer?

Regards,
Frits
 
ilkin esrefli
Greenhorn
Posts: 26
Chrome Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
May be answers are B and D.

http://java.sun.com/blueprints/corej2eepatterns/Patterns/TransferObject.html under Consequences topic there are

Simplifies Entity Bean and Remote Interface
The entity bean provides a getData() method to get the Transfer Object containing the attribute values. This may eliminate having multiple get methods implemented in the bean and defined in the bean's remote interface. Similarly, if the entity bean provides a setData() method to update the entity bean attribute values in a single method call, it may eliminate having multiple set methods implemented in the bean and defined in the bean's remote interface.
Transfers More Data in Fewer Remote Calls
Instead of multiple client calls over the network to the BusinessObject to get attribute values, this solution provides a single method call. At the same time, this one method call returns a greater amount of data to the client than the individual accessor methods each returned. When considering this pattern, you must consider the trade-off between fewer network calls versus transmitting more data per call. Alternatively, you can provide both individual attribute accessor methods (fine-grained get and set methods) and Transfer Object methods (coarse-grained get and set methods). The developer can choose the appropriate technique depending on the requirement.
Reduces Network Traffic
A Transfer Object transfers the values from the entity bean to the client in one remote method call. The Transfer Object acts as a data carrier and reduces the number of remote network method calls required to obtain the attribute values from the entity beans. The reduced chattiness of the application results in better network performance.

Thanks,
 
Parth Twari
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi..

I had marked the answers as B and C

But the answer are A,B

Given in SAI:
Option A is correct because a Transfer Object is used to encapsulate access to remote Entity beans.

Option B is correct because a Transfer Object is used to remove the necessity of making many remote calls to an Entity bean to retrieve all of the bean's data in one remote method call.

Option C is incorrect because Transfer Objects are not directly related to interacting with a database; that is the goal of the Data Access Object (DAO) pattern.

Option D is incorrect because Transfer Objects are not directly related to retrieving remote EJBs; that is the goal of the Service Locator pattern.


Well I feel all answers are ambiguos except for B.
A is also duty of Service locator as is D

Because of the line
table into one object.
in the B option I chose B as answer.
What do you think is the correct answer?

I wanted to know your reaction before I reveal the answer.

So what shall the answers be?
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2277
81
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would choose A and B (isn't it easy when you know the answer....)

A is correct because the Transfer Object is there to make your life on the client side easier. You avoid direct dependence on potentially complex business objects and deal instead with relatively simple bean-like objects.

B is obvious

C It encapsulates access to a database table into one object.

That is what an entity bean (Entity EJB) does.

D.It provides a single point of access to retrieve remote EJBs.

This is more something for a Service Locator/Business Delegate

Regards,
Frits
 
Joe Harry
Ranch Hand
Posts: 10091
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What has a Transfer Object got to do with network latency?
 
Joe Harry
Ranch Hand
Posts: 10091
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is Remote Lookup here called as network latency?
 
Parth Twari
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes Frits you are right in both your answers.
i think i got the answer now

What has a Transfer Object got to do with network latency?


Hi Jothi,
Transfer object is fetched in one remote method call , avoiding the need for multiple fine grained remote calls. Hence reducing network delay.

Is Remote Lookup here called as network latency?


Remote lookup is taken care by Service Locator/Business Delegate

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic