This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Transfer Object pattern Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Transfer Object pattern" Watch "Transfer Object pattern" New topic
Author

Transfer Object pattern

Parth Twari
Ranch Hand

Joined: Jan 20, 2010
Posts: 163
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?


Parth Tiwari
| Pursuing Bachelor of Engineering | OSUM Club Leader | SCJP 6 | SCWCD 5 |...
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1640
    
  23

What do you think is the correct answer?

Regards,
Frits
ilkin esrefli
Greenhorn

Joined: Nov 01, 2007
Posts: 25

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,

SCJP 5
Parth Twari
Ranch Hand

Joined: Jan 20, 2010
Posts: 163
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
Bartender

Joined: Apr 07, 2010
Posts: 1640
    
  23

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

Joined: Sep 26, 2006
Posts: 9345
    
    2

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


SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9345
    
    2

Is Remote Lookup here called as network latency?
Parth Twari
Ranch Hand

Joined: Jan 20, 2010
Posts: 163
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

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Transfer Object pattern
 
Similar Threads
Are these patterns the same
How to know if any of the CMP fileds are modified ?
Passing value to EJB from Servelet
most common patterns
Transfer Object Pattern