SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Member
    Join Date
    Oct 2004
    Location
    nantong
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    What's the difference between application model and the controller in MVC?

    What's the difference between application model and the controller in MVC?
    Since all of them can manipulate the view.

  2. #2
    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)
    A quick and dirty summary is:
    model = business logic/persistant data manipulation
    view = presentation of data from models
    controller = application flow, including selction of view and possibly brokering/marshalling model data to the view
    Jason Sweat ZCE - jsweat_php@yahoo.com
    Book: PHP Patterns
    Good Stuff: SimpleTest PHPUnit FireFox ADOdb YUI
    Detestable (adjective): software that isn't testable.

  3. #3
    SitePoint Guru
    Join Date
    Dec 2003
    Location
    oz
    Posts
    819
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What he said

    Plus - the application model doesnt manipulate the view. The controller choses the view depending on the result of running the business logic in the model's components

  4. #4
    SitePoint Wizard
    Join Date
    Aug 2004
    Location
    California
    Posts
    1,672
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Simplest:
    controller = chooses which model and view
    model = the data
    view = displays the data

  5. #5
    SitePoint Enthusiast m0n5t3r's Avatar
    Join Date
    Jul 2003
    Location
    Romania
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    + the controller isn't a mediator between the model and the view, for more info look at http://wact.sourceforge.net
    m0n5t3r's nest
    --
    earth is 98% full ... please delete anyone you can.

  6. #6
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by arborint
    I wouldn't try to get too pattern happy in PHP. Here is a simple starting layout:

    First, consider your main script the controller. There are a number of different kinds of controllers, but ulitmately its job is to create the Model and the View, connect the Model to the View and then display the VIew.

    Create a separate file containing the Model which is usually a class with methods that allow you to get and put data to/from some data source.

    Create another separate file containing the View which is usually a class with methods to add various content and display itselt. The VIew usually has access to the Model class. Finally it uses some kind of template system plus the data from the Model to create the HTML that is then displayed.

    Of course, the devil is in the details.
    http://www.sitepoint.com/forums/show...18#post1415218

  7. #7
    SitePoint Enthusiast m0n5t3r's Avatar
    Join Date
    Jul 2003
    Location
    Romania
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    good point
    m0n5t3r's nest
    --
    earth is 98% full ... please delete anyone you can.


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
  •