This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hi, 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??
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.
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. Regards Berny Woehrlin
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.
<a href="http://husted.com/struts/book.html" target="_blank" rel="nofollow">Struts in Action</a>