Been thinking a lot about improving loose coupling in my structure. One of the ideas is this: given an url that maps to a module, a controller and action (eg forum/post/view/23), why not create a single point of access for the whole module.
Currently, if I understand things correctly, a module can have several controllers (eg postController, categoryController) each having different actions (eg postController->delete($id)). The frontcontroller calls these controllers based on some routing system.
What about a single forumController as point of access? The forum controller then decides what controller to instantiate. The advantage is that the system only needs this one access point thereby reducing coupling between parts. The disadvantage would be that the forum controller needs some extra work to determine what controller to instantiate, something which is repeated for the other modules.
Any thoughts on this?
module controller as single entry point
Moderator: General Moderators
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: module controller as single entry point
A "module" in this sense is a complete MVC application with all the sub-directories in a module directory. It is a further extension of a Front Controller to allow it to dispatch multiple more, loosely coupled applications (e.g. main site and blog). Code re-usability is the goal -- both in the module and the Front Controller.
You can certainly use multiple Front Controllers (which is what you are describing). That is a good choice when the code needed in the Front Controller for modules is very different. But even that could be mitigated by only loading that code on a module-by-module basis.
You can certainly use multiple Front Controllers (which is what you are describing). That is a good choice when the code needed in the Front Controller for modules is very different. But even that could be mitigated by only loading that code on a module-by-module basis.
(#10850)
Re: module controller as single entry point
If I understand you correctly you are saying that it probably isn't worth it because the difference in front controller code that would suggest such an approach can be handled by the module controllers themselves. Essentailly pushing back that code one level down to the module controllers.
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: module controller as single entry point
I don't know what "module controllers" are. I assume that you are talking about having multiple Front Controllers. There are some cases where you want to do that, but mostly you just use a single Front Controller.
(#10850)