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 Architect Certification (SCEA/OCMJEA) and the fly likes Design Pattern vague 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 » Architect Certification (SCEA/OCMJEA)
Bookmark "Design Pattern vague question" Watch "Design Pattern vague question" New topic
Author

Design Pattern vague question

Joel Schnider
Greenhorn

Joined: Jan 25, 2006
Posts: 5
I found this question here:
http://www.geocities.com/subra_73/SCEA_Practice_Questions.htm
----

31 Julia Fractals Inc. is building a J2EE based application for Order Entry and management of their fractal software. Once the order is taken, it is submitted to a relational database. A provisioning system then queries data and makes appropriate calls to various subsystems using JMS on MQ Series. What design pattern is JMS an example of here?



A Observer

B Mediator

C Adapter

D Bridge

E Visitor



Choice D is correct.



Bridge (GOF 151)"Decouple an abstraction from its implementation so that the two can vary independently." In this case JMS is the abstraction. The implementation could be MQ Series, TIBCO Rendezvous and Vitria Businessware. Hence choice D is correct.

Observer (GOF 293)"Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically." Hence choice A is incorrect.

Mediator (GOF 273)"Define an object that encapsulates how a set of objects interact. Mediator promotes loose coupling by keeping objects from referring to each other explicitly, and lets you vary their interaction independently." Hence choice B is incorrect.

Adapter (GOF 139)"Convert the interface of a class into another interface clients expect. Adapter lets classes work together that couldn't otherwise because of incompatible interfaces." Hence choice C is incorrect.

Visitor (GOF 331)"Represent an operation to be performed on the elements of an object structure. Visitor lets you define a new operation without changing the classes of the elements on which it operates." Hence choice E is incorrect.

----

My question is how can such a vague question have one correct answer? Contrary to the explanation above, I think Bridge is the wrong answer.

I would argue that JMS is an example of the Observer pattern here, since messages on the MOM are used to push out changes to other subsystems.

I could also argue that MOM is a mediator here, since it decouples various subsystems from each other. Instead of subsystem A knowing abt subsystem B and/or subsystem C, it just knows abt the JMS destination where it is supposed to publish its events! The MOM acts like a mediator here.

I may be wrong, but how does one tackle such questions on the exam?
Tom Adams
Ranch Hand

Joined: Feb 07, 2003
Posts: 56
Hi Joel,

Yes - this is an odd question that has made it into the lore of SCEA mock test. I believe the reasoning for calling JMS a bridge pattern has more to do with the nature of the JMS than it does with the scenario presented.

The JMS API is an interface - not an implementation (ok - alot of the J2EE spec works that way). JMS is slightly different because different messaging systems (ie. MQSeries, Tibco etc.) support the JMS API. Having a different class hiearchy for the abstraction (JMS) vs. the implementation allows each to evolve and change independently (Bridge pattern).

That is essentailly how I see the dots are connected between JMS and the Bridge pattern.

HTH
Tom


Tom
Sreenivasa Majji
Ranch Hand

Joined: Jul 12, 2001
Posts: 224
I would see this in a different way. The Observer pattern is used in JMS systems but in this scenario, JMS is just one part of the system. However if you want to choose TIBCO or any other MOM instead of MQ Series , none of the pattern provide an easy change.

When you try to answer these type of questions, try process of elimination method (I always use this in solving sudoku puzzles ). I read this question before and I also thought Observor pattern, because it's a JMS. After reading one more time, I was convinced that the answer given is indeed a right answer.

One of the things I noticed inGOF patterns is they are so close to each other and it's easy to bump into each other.

jus my 0.02$


Sreenivasa Majji
Joel Schnider
Greenhorn

Joined: Jan 25, 2006
Posts: 5
Thanks all, for the clarification.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Design Pattern vague question
 
Similar Threads
My SCEA Part 1Study Notes
here we go again - design patterns from hell
A confusing answer...
Need help with Patterns
design pattern - mock question