wood burning stoves 2.0*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Patterns mock question 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 "Patterns mock question" Watch "Patterns mock question" New topic
Author

Patterns mock question

Zhixiong Pan
Ranch Hand

Joined: Jan 25, 2006
Posts: 239
Which design pattern does the following description best match?


"One of the main drivers for this pattern is to minimize network traffic. It does this by providing a local representation of a remote object. This pattern is associated with the idea of a cache, i.e. an area where frequently accessed data can be stored for rapid access."

A. Transfer Object
B. Model-View-Controller
C. Business Delegate
D. Service Locator



My original answer is C, because that pattern use a local cacher for Transfer Object, but the provided answer is A. Do you think if that is a bit confusing?
That is from examulator/ ► SCWCD/ ► Quizzes/ ► Design Patterns Quiz/ ► Attempt 1, http://www.examulator.com/moodle/mod/quiz


SCJP 1.4 SCJD
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

A Business Delegate is mainly used to hide the complexity of remote communications to clients. I don't think that this can be the answer. The explanation clearly matches answer A.


[My Blog]
All roads lead to JavaRanch
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
This is a tricky question and a great example of the problem with multiple choice questions and software design.

A Transfer Object is for transferring data between server-side and client-side code. It may or may not represent a server-side object (remote object). It may simply be used for moving data. The concept of a "cache" is not asscociated with using transfer objects either, in my experience.

The question is confusing and a more appropriate answer would be C. Business Delegate.

Coarse-grained methods of a Business Delegate can also reduce or minimize network traffic. However, a Business Delegate may or may not represent a server-side (remote) object.

The only way to truly answer a question like this correctly is to somehow think exactly like the person that created the exam or the author of the question. And this vaguely has very little to do with understanding software design patterns. There are too many variations and strategies for each design pattern. Hence, it is very difficult to create a good multiple choice question with a single "correct" answer for software design concepts, e.g. design patterns.

Chinmaya Chowdary
Ranch Hand

Joined: Apr 21, 2008
Posts: 432
Hi, Zhixiong.

Study, 'Peabody' notes on design patterns. This will clear many confusions.
avi sinha
Ranch Hand

Joined: Mar 15, 2009
Posts: 452

Frank Bennett wrote:

The question is confusing and a more appropriate answer would be C. Business Delegate.

Coarse-grained methods of a Business Delegate can also reduce or minimize network traffic. However, a Business Delegate may or may not represent a server-side (remote) object.



Business Delegate can never be the answer. it can never reduce the network traffic.


It does this by providing a local representation of a remote object.


Transfer Object performs this function.

This pattern is associated with the idea of a cache, i.e. an area where frequently accessed data can be stored for rapid access."


Service locator provides the facility of caching.

The question is quite confusing as no pattern ( transfer Object or Service locator) satisfies both the condition completely .

But i think the answer should be Service locator as it is associated with catching and question is dealing with only representation not a true copy of the object.

Avi Sinha


SCJP 5.0 SCWCD 5.0
Prateek Parekh
Ranch Hand

Joined: Apr 17, 2010
Posts: 34
It does this by providing a local representation of a remote object.


This is all you need in the question to determine that its a Transfer Object.
avi sinha
Ranch Hand

Joined: Mar 15, 2009
Posts: 452

Prateek Parekh wrote:
It does this by providing a local representation of a remote object.


This is all you need in the question to determine that its a Transfer Object.


but what about caching??? Transfer object is not associated with caching.

Avi Sinha
Petar Thomas
Ranch Hand

Joined: Oct 11, 2009
Posts: 234
I am not good enough at this in this moment.

I think that the term "network traffic" was about a database connections to the clients directly ... in a two-tear 'system' which was before, i don't know, nintees, eightees, and on that ...was invented "three-tier". So it could be something like serving the client (almost directly) from database, and to me it sounds, honestly, like jammed database is network traffic (too big). That partially touches what mr. Frank Bennett writted:
... is to somehow think exactly like the person that created the exam or the author of the question. And this vaguely has very little to do with understanding software design patterns. There are too many variations and strategies ...


It is not just one person, the one who writes the question, and what he, or she, was thinking with, but alltogether, history and past, many persons... in this case.

TransferObject IS
It is also called - a Data Transfer Object


ServiceLocator is that - ONE OBJECT -
It could be like this:
first there was a MVC
then all the pages trippled (MVC)
then all C's became ONE
Business Delegate was ... what stayed on the table...
All Business Delegates had to contact JNDI... (duplication code)
So Service Locator was better, all Business Delegates were contacting one Service Locator,


I would show you my note book with my writings....

(You can find it in the book)


In the JSP, every single small EL on just only a page
made a connection to the database,
every single one, one connection, one network call,
and separate transaction...
...
plus + generated exceptions on the page,
so the page had to be ... the one that handels exceptions as well...

So it all worked.






(Data) Transfer Object holded many instance variables... data travelled.... from database to the JSP ordinary page.. displayed... and rendered...

But only one.



The whole poant of this question is about two things:
1. Distributed web app ( JVM's )
2. Struts (!)


So... Let's say that it was not about design patterns, and that it was not about looking at one design pattern at the time, for it self, just....
The design patterns were simply consequences..


Mr. Christophe Verré wrote:
A Business Delegate is mainly used to hide the complexity of remote communications to clients. I don't think that this can be the answer. The explanation clearly matches answer A.


, but, from the next sentence (form http://java.sun.com/blueprints/corej2eepatterns/Patterns/BusinessDelegate.html )
the presentation-tier components are vulnerable to changes in the implementation of the business services:

.. i would emphasise the word vulnerable ...

becaouse I think that it is not about the complexity here, or hiding, .... The wish, need, intention... obstacle.

Mr. Chinmaya Chowdary wrote:
Study, 'Peabody' notes on design patterns. This will clear many confusions.

And I think that the 'Peabody's notes are ok, but it is nice to see drawed lines and boxes from the book.

Mr. Avi Sinha wrote:

Service locator provides the facility of caching.

The question is quite confusing as no pattern ( transfer Object or Service locator) satisfies both the condition completely .

But i think the answer should be Service locator as it is associated with catching and question is dealing with only representation not a true copy of the object.


"The question is quite confusing as no pattern ( transfer Object or Service locator) satisfies both the condition completely . "

- it is not about ONE pattern....

In the question of this topic was written:
It does this by providing a local representation of a remote object. This pattern is associated with the idea of a cache, i.e. an area where frequently accessed data can be stored for rapid access."


It does this by providing a local representation of a remote object.

That is called a stub.


There is also another thing .. that "the data" which left the database is in that moment 'stale' (too old).

And here the thing is:

"This pattern is associated with the idea of a cache, i.e. an area where frequently accessed data can be stored for rapid access."

-the idea-


I understand the idea:
"Service Locator provides the facility of caching"

But... it's a good thing that people speak "the same language", and that people understand each other... So in the most common sense, technically speaking, maybe it is not a cache...

Anway, the idea, the meaning of it, what was meant... is important....

and rapid access. One method call vs. one network connection. That is also - cache. (Speed)
So...


And that's why this is not true:
"The question is quite confusing as no pattern ( transfer Object or Service locator) satisfies both the condition completely "

I would say that is not pattern satisfying condition, but that condition "creates" patterns... on-a-way. Struts and distributed app. Question is about Struts and distributed app.


"But i think the answer should be Service locator as it is associated with catching and question is dealing with only representation not a true copy of the object."

I don't know if that really has to be so, like that. Probably it can be a true copy as well, if someone wants. Service Locator, in this question , IS for database, but only for Service Locator ...part of it.

JNDI.

Mr. Avi Sinha also wrote:
but what about caching??? Transfer object is not associated with caching.

It is.

Every object does it's job. Transfer object transfers data and therefore performs caching. Caching is not only the cache, the place, the data, the copy, caching is also and action of caching. Caching and cache are even two different things, if someone wants to make them so. And for the purpouses of displaying data on the screen of the browser it is not needed an exact memory copy of database, representation of data is just fine, only that it has to be true.

Mr. Frank Bennett wrote:

A Transfer Object is for transferring data between server-side and client-side code. It may or may not represent a server-side object (remote object). It may simply be used for moving data. The concept of a "cache" is not asscociated with using transfer objects either, in my experience.


Yes it is. In a moment when Transfer Object with data leaves, the data is stale( too old).
cache - maybe isn't transfer object, but... caching is.

Mr. Frank Bennett also wrote:
The question is confusing and a more appropriate answer would be C. Business Delegate.

Coarse-grained methods of a Business Delegate can also reduce or minimize network traffic. However, a Business Delegate may or may not represent a server-side (remote) object.


Anyway, I just think that "coarsly-grained" is meaning something a litlle bit different.




[Thumbnail for IMG000631.jpg]

avi sinha
Ranch Hand

Joined: Mar 15, 2009
Posts: 452

Petar Tomičić : i have gone through your response, but couldn't understand what you want to say.

Avi Sinha
Petar Thomas
Ranch Hand

Joined: Oct 11, 2009
Posts: 234
I apologize.

avi sinha
Ranch Hand

Joined: Mar 15, 2009
Posts: 452

Petar Tomičić wrote:I apologize.



there is no any need of that. please conclude your response.

Avi sinha
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1638
    
  23

Hi All,

Avi
but what about caching??? Transfer object is not associated with caching.

It actually is reducing network traffic by combining remote calls
SUN Core J2EE Patterns
Transfer Object: 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.

The Service Locator also caches, but only the address of the service, not the actual data
Regards,
Frits
Petar Thomas
Ranch Hand

Joined: Oct 11, 2009
Posts: 234
The question it self is not, by my opinion asking about the knowledge about one design pattern, but I think that the question is asking about:

Remote Model Diagram.


I drawed a remote model diagram in a photo paint and included it in attachment.
Steps are:

1 - Register user services with JNDI
2 - Use Business Delegate and Service Locator to get the Manage Customer stub from JNDI
3 - Use the Business Delegate and the stub to get the "Customer Bean", which in this case is another stub. Return stub's reference to the controller
4 - Add the Customer stub reference to the request
5 - The controller forwards to the View JSP. The JSP gets a reference to the Customer bean (stub) from the request object.
6 - The View JSP uses EL to get the Customer Bean properties it needs to satisfy the original request.



[Thumbnail for Remote_Model_Diagram.jpg]

[Thumbnail for Transfer_Object.jpg]

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Patterns mock question
 
Similar Threads
Value Object (VO) vs. Transfer Object (TO) vs. Data Transfer Object (DTO)
Design Pattern Question
mock exam question related to design pattern
HF - Most difficult Q on patterns
Transfer Object Pattern