SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Apr 2011
    0 Post(s)
    0 Thread(s)

    MVC design clarification

    Hey all,
    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:
    MVC Concept.jpg

    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:
    MVC Concept2.jpg

    Is this correct? Any suggestions to the flow of things?

  2. #2
    Founder of Primal Skill Ltd. feketegy's Avatar
    Join Date
    Aug 2006
    0 Post(s)
    0 Thread(s)
    You're mixing 3 tier application architecture with MVC. MVC is NOT 3 tier.

    Basically MVC stands for Model-View-Controller. Model handles the data (database, file, whatever), View controls the layout (mostly html, JSON, and other front-end stuff), so the View is responsible of instantiating anything that's needed for the view (CSS, Javascripts, Flash, etc.) and finally the Controller is the business logic of the application or inner page.

    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:


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts