This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
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

Front Controller and Business Delegate

 
Amandeep Singh
Ranch Hand
Posts: 850
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?

Choose 2 options:

1)Business Delegate

2)Transfer object

3)Front Controller

4)Session Facade

5)Model View Controller

The correct option is 1 and 3.

But according to me the correct option should be 3 and 5

This is from Enhtuware.
Please do advise.
 
Deepak Chopra
Ranch Hand
Posts: 433
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Amandeep, In order to score good in design pattern, I recommend you to study design patterns by peabody. Its only two pages.

MVC is used when when we have different presentation logic as per the client.
design patterns questions are tricky. The moment you thought of MVC, you must had think about extracting the JSP code out of servlet and create a different presentation layer.
But Here the question is asking about the avoiding of Duplicate code.
Business Delegate help us to provide a uniform interface to its client.
We can extract the duplicate code of services look up(which is more or less same) and create an all together different layer - Business Delegate.

Front Controller is also used to apply same processing logic to all the requests and to avoid duplicate code.

Creating Views through servlet is something which is not good, but it is not duplicating of code. We can still create Views without duplicating.

I hope it clears you.
 
Amandeep Singh
Ranch Hand
Posts: 850
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Awesome Sunny, i would try to link the specific features of a particlar pattern to the hint's given in the question.
 
Deepak Chopra
Ranch Hand
Posts: 433
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anyway When are you going to take your exam.
 
Amandeep Singh
Ranch Hand
Posts: 850
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am giving exam on Sept 2.
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another poor question. These patterns are all related. All of them can be used to solve the issue. Or, usage of one normally means you are using the others. MVC, Business Delegate, Transfer Object, Session Facade... all combined provide a solution.

To micro analyze and magically guess at the answer the exam creator thinks is correct is not a good way to learn about design patterns.

"service methods have grown big" is extremely vague.
[ August 29, 2008: Message edited by: James Clark ]
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree that "methods have grown big" is vague. You have to make your best guesses.

You have to approach it asking "Why are they too big?"

In order of likelihood in a typical application:
Situation 1) Too much business logic - you can abstract this closer to the backend... I think that's why the question author chose "Business Delegate" since that pattern is the closest of the SCWCD patterns to the backend, but quite honestly your Business Delegate shouldn't have business logic... you're better off putting that logic in a service class or Session Facade. If your service class or Session Facade is remote, then you can use a Business Delegate to hide the complexities of communicating those remote components.

Situation 2) Some crazy dude has us in a Model 1 architecture where the Servlets are all writing html to the response directly. Or maybe the Servlets are making direct database calls. Bring in the MVC!

Situation 3) Too much boiler-plate code - if every Servlet does some of the same exact work, you could move that code to a Front Controller.


So my answer of likelihood would be:
Session Facade
MVC
Front Controller

However, Session Facade is no longer one of the SCWCD's Big 6 patterns and so will never be a correct answer on the real exam...

So, with that in mind, MVC and Front Controller are the best "real exam" answers. Good job.
 
Paul Anilprem
Enthuware Software Support
Ranch Hand
Posts: 3817
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the input, Mark & James. We will improve it.

Originally posted by James Clark:


"service methods have grown big" is extremely vague.



Expect such vagueness in the real exam as well
[ August 29, 2008: Message edited by: Paul Anil ]
 
Amandeep Singh
Ranch Hand
Posts: 850
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Peabody...

You are genius guy. I am already benefitting from your note's for mock exam's.

Let's see how much i do benefit in real exam.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic