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

Question on design pattern

 
Abhishek Sharma
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers,


here is one question that i encounter.


As per my knowledge it should be C (MVC) but mock answer suggest it is B.

please provide your suggestions.

Abhishek
 
Ali Gohar
Ranch Hand
Posts: 572
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Front Controller will be more close answer whereas MVC will be broder because Front Controller separates the Presentation and Business logic layers
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Abhishek, I agree with you that MVC is the better answer.

Front Controller's main purpose is to centralize the common business logic. But not all of the business logic is common and so it needs to go somewhere. To completely keep the business logic out of the views, we still need more classes to hold the business logic that isn't common.

A good choice for the extra business logic is the Command pattern. HFSJ page 739 illustrates how this is done using Struts (Action objects follow the Command pattern). After putting all this together, you pat yourself on the back and realize that you've also implemented the MVC pattern.

Oh. How did that happen?

The MVC pattern's entire purpose is the separation of concerns. Basically, if you separated business logic from views (and didn't do anything goofy with your Model to break MVC), you've more than likely implemented MVC.

Bottom line, Front Controller by itself does not separate business logic from the views.

By the way, Abhishek, please check out the JavaRanch Naming Policy and update your display name accordingly. Thanks.
 
Ali Gohar
Ranch Hand
Posts: 572
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Front Controller's main purpose is to centralize the common business logic. But not all of the business logic is common and so it needs to go somewhere.


I disagree, in my opinon Front Controller is not meant for implementing any business logic, it actually controls the flow of your application and delegates the request to appropriate handler, which can further call the appropriate business handlers.

So it actually is a layer between the view and our business layer

This is what i think
 
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 centralized application flow is a facet of the Front Controller. I also should have called it "common control logic" rather than "common business logic".

That said, I do disagree with the statement: "So it actually is a layer between the view and our business layer"

It sounds as though your application flow for each incoming request goes something like this (which is typical):
Front Controller > "Business Handlers" > Views

The Front Controller is not separating your Business Handlers from the Views.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic