ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

True MVC

March 05, 2008 4:25am

Subscribe [3]
  • #1 / Mar 05, 2008 4:25am

    xwero

    4145 posts

    After reading this blog post i got curious and got this of wikipedia (ok not the best source)

      1. The user interacts with the user interface in some way (e.g. presses a button).
      2. A controller handles the input event from the user interface, often via a registered handler or callback.
      3. The controller accesses the model, possibly updating it in a way appropriate to the user’s action (e.g. controller updates user’s Shopping cart).[3]
      4. A view uses the model (indirectly) to generate an appropriate user interface (e.g. the view produces a screen listing the shopping cart contents). The view gets its own data from the model. The model has no direct knowledge of the view.
      5. The user interface waits for further user interactions, which begins the cycle anew.

    This part from point 4 got me puzzled; A view uses the model (indirectly)
    How does a view uses the model indirectly if it may not be a part of the controller (see first url)? I’m guessing the observer pattern must be implemented in a true MVC framework.

  • #2 / Mar 05, 2008 4:58am

    wiredesignz

    2882 posts

    Very good reading xwero. Thanks.

    I personally use this page for a decent reference to MVC:
    http://www.phpwact.org/pattern/model_view_controller

    I absolutely agree with seperation of concerns and try to follow the MVC principles, and constantly think how each component in my application will behave if I change another. `Will this controller need recoding if the code in the Model changes etc`

    In any event I believe we can still develop our own code in CodeIgniter using proper MVC rules even though every code example you see on the CI site violates the basics.

    MY_2C

  • #3 / Mar 05, 2008 5:52am

    xwero

    4145 posts

    That is a more elaborate reference thanks. I’ve read it before, i even think i got the Observer pattern idea from them 😊

    I’m glad it states in the user guide CI is loosely based on the MVC pattern. Maybe we can speak of MVC like segmentation? I think the best example is found in the symfony MVC explanation. Listing 2-5 would be a violation of the MVC pattern as i understand the view.php should directly make contact with the model function because it’s a not model altering function?

    ps for symfony users : I’m just talking about the example code on that page not about the framework as a whole

  • #4 / Mar 18, 2008 5:22pm

    rick.b

    1 posts

    The original MVC was the work of Trygve M. H. Reenskaug while he was at PARC in 1978… For more info, some papers etc see this (his) webpage…http://folk.uio.no/trygver/themes/mvc/mvc-index.html

  • #5 / Mar 19, 2008 7:18am

    Glen Swinfield

    113 posts

    4. A view uses the model (indirectly) to generate an appropriate user interface (e.g. the view produces a screen listing the shopping cart contents). The view gets its own data from the model. The model has no direct knowledge of the view.

    This is correct, the view uses data from the model, but the two are linked through the controller (hence indirectly) - the view has no knowledge of the model and the model no knowledge of the view.

    It could be explained in much better way though I think.

  • #6 / Mar 19, 2008 7:33am

    wiredesignz

    2882 posts

    This discussion was attempting to look beyond using the Controller for data transfer, In true MVC it is not the job of a Controller to manage data.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases