• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Question about the FrontController

 
Ranch Hand
Posts: 751
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys, I'm still thinking if I understood the front controller correctly. I have a class that processes a response attribute named "page". Then, depending on its value I have multiple if statements and depending on the condition met, forwards to a specific page. Is this an example of the front controller? Or is this just another bad practice I'm doing? I have read Bear's article about this but unfortunately I just don't get it...
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Timothy Sam:
I have a class that processes a response attribute named "page".



Please clarify regarding "response attribute"? There's no such animal. Can I assume that you mean request parameter?

What are you are doing is indeed implementing a front controller (if I understand you correctly), but using nested if's is a poor way to do it. That means that every time you add a new Command to the app, you need to add and if block for it.

Rather, a typical front controller will use a configuration of some type to map the "command verb" to a class that it dynamically instantiates. That way, nothing need be hard-coded into the front controller itself, and commands can be added to the system without adding any code (except for the command class itself, of course).

I do need to apologize a bit... it was originally my intention to follow up on the article you mentioned with one on the design of just such a front controller which I have written. But other writing tasks have taken precedence and I haven't been able to get to it. I hope to have it available for the next Journal though...
 
Timothy Sam
Ranch Hand
Posts: 751
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Bear. The animal I'm referring to is indeed a request parameter and not a response attribute. I understood everything fully, thanks a lot.
 
reply
    Bookmark Topic Watch Topic
  • New Topic