SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    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)

    A different perspective on Model-View-Controller

    While having a discussion on new-media (web/software) in opposition to traditional (textual) media, it occurred to me that the metaphore of MVC could be used to explain the structure of a webpage. The markup (HTML) represents the Model, the stylesheet (CSS) represents the View and the behaviours (javascript) handles the Controller-role.
    This way of describing the media is analogous to the classical image-analysis, witch operates with a semantic and a syntactic layer, somewhat similar to the Model and the View.

    After googling a bit, I found this article, in witch the author uses the same observation.
    http://www.oreillynet.com/pub/a/java...ential_js.html

    I recognize that this is bending the conventional meaning of MVC, but I think it makes a lot of sense. It does to me anyway, and I'm quite sure that W3C has atleast been aware of it while defining the XHTML standard.

    Has anybody stumbled upon some texts dealing with this subject ? Preferably something a bit more academical than the tutorial linked to above.

    Off Topic:

    I know that this hasn't got much to do with PHP, but it does have a lot to do with MVC, witch has been discussed a lot on theese forums, so I ask the moderators to leave the post in this forum.

  2. #2
    SitePoint Guru
    Join Date
    Dec 2003
    Location
    oz
    Posts
    819
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The css definitely would be rendering the view, but I'm thinking that the html would represent the controller, and delegates logic (things to do based on input) to javascript (which would become the model).

    Interesting idea though. Thanks for the comment.

  3. #3
    SitePoint Wizard
    Join Date
    Aug 2004
    Location
    California
    Posts
    1,672
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ajax suggest something like this as well, with a Javascript controller feeding data to the browser's HTML/CSS engine to generate the page.
    Christopher

  4. #4
    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)
    As far as I see it, MVC is a thought-model (is that a word?) - it can be used to explain structures on different levels.
    Consider a traditional php-served webpage ; On the macro-level, everything happening clientside is consider the View, while Controller-stuff happens in the php-script and the Model is covered by filesystem and a relational database. With AJAX technology, the Controller is shifted more towards the client.
    At the same time, each macro-component can be decomposed into a "local" MVC. Using an MVC-aware framework for PHP is an example of this, and as we push more code onto the client (AJAX) something similar will be needed there. The macro-level Model-component (The database) may use VIEW's (a SQL-feature) and stored procedures may take care of local Controller-stuff.

    However, if we percieve a webpage as a closed system (ignoring the webserver and even the browser), it becomes sensible to understand the HTML-CSS-JS triad as reflecting M-V-C. If you consider the paradigmshift between HTML4 and XHTML I think it becomes quite appearent. In HTML4 Model and View weren't seperated - the major change (apart from syntax) to XHTML is exactly the seperation between semantics and presentation. Most clearly exemplified with the <b> vs. <strong> tags.
    Btw ; From the javascript-perspective the HTML is accessible through the DOM (Document Object Model). Go figure.
    Last edited by kyberfabrikken; May 31, 2005 at 05:19.

  5. #5
    simple tester McGruff's Avatar
    Join Date
    Sep 2003
    Location
    Glasgow
    Posts
    1,690
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think javascript, as a programming language, isn't restricted to any one layer. It could appear anywhere: model, view or controller. A js alert would be all three.


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
  •