cshoffie — 2011-12-11T21:13:10-05:00 — #1
I've been studying the concept of MVC frameworks. I've watched quite a few tutorials on Youtube but I'm still unclear about some things. Such things as the design of the framework as well as which controls the actual functionality of the application: the "M" or the "C". The various tutorials on Youtube aren't very clear on which controls the LOGIC and really where it gets outputted to. For example: Is it the page controller that handles all of the if/else that comes from the page's model? Once those computations are done, then the same page controller outputs it to the view?
I've included a flow chart I've made illustrating my current understanding of what an MVC framework is:
Step 1: User types in a URL or clicks a link.
Step 2: URL is interpreted by an interpreter to determine the controller, function, and parameters.
Step 3: Controller, function and params get sent to a main controller (or dispatcher) which then calls the requested controller (page).
Step 4: Page controller processes function and params and calls a page model depending on which function was requested.
Step 5: Page model calls it's dependent classes in order to output the information needed.
Step 6: Page model outputs information to page controller.
Step 7: Page controller assigns it to the view.
Step 8: View processes and displays information to user.
Or does the model call the classes and handle all of the logic (business) and then outputs to the view? If this is the case, then the page controller is simply part of the routing system same as the URL Interpreter and Main Controller? Here's another illustration:
Is this correct? Any suggestions to the flow of things?
feketegy — 2011-12-20T11:14:00-05:00 — #2
You're mixing 3 tier application architecture with MVC. MVC is NOT 3 tier.
The controller's role is to pass on the information of the model to the views where the final output can be rendered for the users, basically controllers control the flow of the whole application.
Every request should go in the controller which then decides which model and view to load.
Also, you can read more on Model-View-ViewModel pattern too which takes MVC a step further: http://en.wikipedia.org/wiki/Model_View_ViewModel