Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Query Related to Design Patterns

 
Amit Tayal
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Please let me know the answer for belwo mentioned question:

Q. You have taken over an old web application that contains a servlet for each use case. These servlets have become difficult to maintain because the service methods have grown big. Also,since the use cases are similar, lot of code has been repeated accross the servlets.
Which patterns can you apply in this situation?

Select 2 correct options
a Business Delegate
b Transfer Object
c Front Controller
d Session Facade
e Model View Controller


As per solutions, option a & c is right.
My question is why option "a" is right and "e" is wrong.

Amit
 
Shivani Chandna
Ranch Hand
Posts: 380
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm yes even I saw this question in javaranch mock exam.
And even I had selected c & e.

Not sure of why a? . Me too having the same doubt.

Rgds.
 
Nikhil Jain
Ranch Hand
Posts: 392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Even I had selected C & E. Answer (a) is def. wrong..from my point of view. Can anybody explain??
 
Amit Tayal
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Need help from Java Gurus
Please verify the above mentioned statment.

Amit
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
MVC doesn't really solve the problem. Business Delegate doesn't either.

There are a lot of horrible design pattern mock questions out there (like this one). They often give a scenario of absolutely no design and ask which pattern or two will solve all of your problems. And often the "correct" answer doesn't make sense.

A Business Delegate decouples the presentation tier and the business logic classes (aka business services). In this scenario, there were no business services. The "services" mentioned in the question are in the servlets.

The first step toward fixing the problem is to refactor the code to draw the business logic out of the servlets and into separate business service classes. Then, if necessary, maybe the servlets could use a Business Delegate to help lookup the business services, particularly so if they are remote.
 
Amit Tayal
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Marc.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic