This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

why do we need Application Controller?

 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am confused with the need to have a separate pattern called Application Controller. Whatever it does Front Controller also does - controls the flow of the application (rather views and actions).
[ October 01, 2007: Message edited by: ankur rathi ]
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seems like the same pattern to me.

The front controller controlls the application flow and logic.

-Cameron McKenzie
 
eduardo ferreira
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No they are not.

- Front controller : Struts SERVLET.
- Application Controller : The struts actions you code.
 
amit taneja
Ranch Hand
Posts: 813
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by eduardo ferreira:
No they are not.

- Front controller : Struts SERVLET.
- Application Controller : The struts actions you code.


can you please explain it in detail like

when you say struts servlet, it is struts action class in struts framework, whihc we don't write but that operates on the basis of struts-config.xml

and when you say "application controller" what you mean ?
we code view and action class/ which we extends the dispact action where we logically send action forward object ? i think
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


eduardo ferreira

No they are not.

- Front controller : Struts SERVLET.
- Application Controller : The struts actions you code.




It would seem that this article sees the Struts action Servlet as implementing the Application Controller pattern, while the struts actions you code being an implementation of the command pattern.




n Struts terminology, this class is called an action although you'll also see this general pattern referred to as the command pattern. At runtime, the Struts controller (a Java servlet) maps the incoming request onto an action class and calls the execute() method, which contains the (business) logic required to service the request. In the example, this logic is responsible for locating the Blog instance and making it available (via the request) so that the recent list of blog entries can be presented back to the user. As with all of the others, this example uses JSP as the view technology, although you'll notice from the code above that we don't explicitly say, "please now show JSP page X". We'll cover this shortly but for now, here's the JSP page itself.


Struts Command Pattern


In object-oriented programming, the Command pattern is a design pattern in which objects are used to represent actions. A command object encapsulates an action and its parameters.


Command Pattern Description

-Cameron McKenzie
[ October 01, 2007: Message edited by: Cameron McKenzie ]
 
eduardo ferreira
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by amit taneja:


can you please explain it in detail like

when you say struts servlet, it is struts action class in struts framework, whihc we don't write but that operates on the basis of struts-config.xml

and when you say "application controller" what you mean ?
we code view and action class/ which we extends the dispact action where we logically send action forward object ? i think


Yes, I think the front controller is the strut's servlet you declare on web.xml file (org.apache.struts.action.ActionServlet), and I see every action you code on your application (extending org.apache.struts.action.Action) as an application controller coded using the command pattern.

I don't think it's really useful to discuss too much beyond this point as the patterns on j2ee book are very abstract. I had never read this book before, and I'm reading it for the architect exam. I'm really hating this book: the patterns are not well explained, it gives you a LOT of bad examples (like coding a front controller using a JSP and stuff like this) and contains blocks senseless texts, so you have to skim through pages and pages. The problem is that I don't think that we have any other source for this subject, so we will have to read this book anyway, but with some care.
[ October 02, 2007: Message edited by: eduardo ferreira ]
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eduardo,

Don't you know you're not supposed to say anything except great things about that book! That's like saying bad things about The Quoran or The Torah or The Bible. It's just not wise!

Actually, I'm glad you said it. I too felt the book was an awful read. You should read a book like that, and for every pattern have one of two responses:

OMG! I've been doing that for years, but I never knew it was a pattern! Kewl!

or

OMG! I've been struggling with that for years, and I never realized how easy a problem it was to solve! Kewl!

Instead, the reaction to every page seems to be the same:

Zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz.......

I agree with you about the book. And it's the lack of clarity of those types of references that makes us wonder what someone is talking about when they say Front Controller, Application Controller or Command Pattern.

-Cameron McKenzie
 
amit taneja
Ranch Hand
Posts: 813
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
which book you are talking about ?
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pretty much every book that has the words "Design" and/or "Pattern" in the title.

-Cameron McKenzie
 
Frank Kuepper
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The distinction Martin Fowler gives may be mor helpful than corej2eepatterns. See

http://www.martinfowler.com/eaaCatalog/frontController.html
http://www.martinfowler.com/eaaCatalog/applicationController.html

Seeing it this way, the two patterns make sense.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic