SitePoint Sponsor

User Tag List

Page 3 of 3 FirstFirst 123
Results 51 to 56 of 56

Thread: MVC confusion

  1. #51
    simple tester McGruff's Avatar
    Join Date
    Sep 2003
    Location
    Glasgow
    Posts
    1,690
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by 33degrees
    Generally, I've seen two approaches; either the controller extracts data from the model and pushes it to the view, or the controller passes the model to the view, which pulls the data it needs.
    Or, the controller simply tells the view to update itself with the view fetching its own data. If the controller ends up elbow deep in the view you wouldn't have the clean separation of controller and view that MVC is all about. Input/application controllers have fundamentally different responsibilities compared to view classes.

  2. #52
    SitePoint Guru 33degrees's Avatar
    Join Date
    May 2005
    Posts
    707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by McGruff
    Or, the controller simply tells the view to update itself with the view fetching its own data. If the controller ends up elbow deep in the view you wouldn't have the clean separation of controller and view that MVC is all about. Input/application controllers have fundamentally different responsibilities compared to view classes.
    I'm not sure how what you're describing is different than what I said about the "controller passes the model to the view, which pulls the data it needs."?

  3. #53
    simple tester McGruff's Avatar
    Join Date
    Sep 2003
    Location
    Glasgow
    Posts
    1,690
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The difference would be that the controller wouldn't know which domain objects the view needs to access. It just selects a view and tells it to render itself.

  4. #54
    eschew sesquipedalians silver trophy sweatje's Avatar
    Join Date
    Jun 2003
    Location
    Iowa, USA
    Posts
    3,749
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I agree with McGruff here. I think of "Model" as really "any of the collection of Domain Model layer objects" and my View/ViewHelper classes pick and choose among these to select what domain data is required for the presentation.
    Jason Sweat ZCE - jsweat_php@yahoo.com
    Book: PHP Patterns
    Good Stuff: SimpleTest PHPUnit FireFox ADOdb YUI
    Detestable (adjective): software that isn't testable.

  5. #55
    SitePoint Guru 33degrees's Avatar
    Join Date
    May 2005
    Posts
    707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by McGruff
    The difference would be that the controller wouldn't know which domain objects the view needs to access. It just selects a view and tells it to render itself.
    I see what you mean, and it's a valid point of view, but I'm of the opinion that anything that isn't strictly presentation logic doesn't belong in the view layer. I've done it both ways myself, and I find that having the loading done in the controller layer to be a cleaner seperation of concerns. Both approaches have their advantages and disadvantages, so I'd say they're both valid.

  6. #56
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In the past I've more or less had to pass the model data to the view layer via the controller, and this could be messy at times. So I'm thinking that maybe using the ViewHelper, to select which model data to use, and pass the ViewHelper to the view would be more interesting?

    So the controller only needs to be concerned with that ViewHelper(s) it needs, for a given view. So, is that approach going to be any better huh?


Bookmarks

Posting Permissions

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