Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

MVC Architecture -- Multiple Controllers

Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an application where the login is controlled by the Main Controller(Which in turn calls helper objects to authenticate) and then serves the main page.
When the user clicks on an option presented in the main page, the application then calls another controller which is the main controller for that module.
I talked to a senior architect and he says that this sort of design is wrong.
Any thoughts??
Ranch Hand
Posts: 2676
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It sounds to me like it breaks the MVC pattern, but I am not an expert on the matter. Are you asking specifically about Struts? If so, the controller is built to support multiple modules through parameters in the web.xml file.
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rahul,
I prefer to have on MainAction class which handles all the standard things any Action should contain in a similar way: Session management, user authentication (by calling a Helper class...), etc. Then I subclass this MainAction and add the module-specific controller logic...
Hope this is some help.
Berny Woehrlin
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some applications do use multiple "controllers", but most architects now seem to prefer using a single "front controller" to receive all the initial requests. The front controller can then delegate the actual processing to a "dispatcher".
Multiple controllers often add complexity without any additioinal benefit. Since servlets are multithreaded, there is no performance advantage of using multiple controllers when one would do as well.
The Struts framework uses a single front controller (the ActionServlet) and multiple dispatchers (the Actions). This generally works quite well, but I often think allowing mutliple front controllers would make team development easier. In Struts 1.1, we are experimenting with application modules, but it seems like we are starting to replicate features already found in the container.
So, there is no technical advantage to having multiple controllers. But it might simplify configuratiion issues when each team (or "module") can use its own controller.
HTH, Ted.
The human mind is a dangerous plaything. This tiny ad is pretty safe:
the value of filler advertising in 2020
    Bookmark Topic Watch Topic
  • New Topic