Professional PHP

PHP Programming, Web Development, PHP Advocacy and PHP Best Practices.
« Installing Web Applications
Mac Mini and PHP »

The value of MVC

November 28th, 2004

John Lim has a recent rant asking Is MVC over-designed crap?

I used to think so, but now having refactored some existing applications to use MVC, i see the value.

In my unscientific comparison of PHP and Java Job Markets six of ten java jobs ask for some Struts knowledge. While I am willing to believe that Java programmers are masochists, one cannot discount the possibility that there is value in its use.

Another way to approach the issue is to look at this Java framework comparison. It compares the same CRUD application written in Struts, Spring, JSF, Tapestry, and WebWork. The thing that I found striking about the comparison was how “crufty” the struts implementation was in comparison to the others. And yet, none of the others were mentioned in my 10 job sampling. Again, it seems like Struts must bring something to the table.

It is worth remembering that Struts did not originate inside Sun and get pushed out as a bloated vendor standard. Rather it evolved into a de-facto standard of what MVC means on the web as an open source project. I think this growth in use is an indication that web MVC has value.

Is there confusion over MVC?

Yes. Many of the “what goes where” arguments are a bit like trying to count the number of angels that can dance on the head of a pin. In practice, a 100% separations M, V, and C concerns is almost impossible and not even desirable. Yet, it turns out that making some kind of distinction between the concerns is helpful.

Adding to the confusion is the fact that most MVC frameworks do more than just MVC.

I tend to find that the broader your definition of MVC, the more trouble you are going to have with the “what goes where” and “where does this go” questions. In that light, I tried to write up a fairly strict and complete definition of Model View Controller.

I like to use an analogy from the GUI era. If you were writing a GUI application for the Macintosh in 1987, it was hard. Hello World was 50,000 lines long. (at least it seemed like it.) You were responsible for your own event loop and dispatching OS events into your application. Every application re-invented the wheel.

If you are writing a windows GUI application in 1997, you would use a tool like Visual Basic or Delphi to apply the MVC pattern (well really DocumentView variant) to your GUI applications. Both tools take the OS event loop (controller) away from the programmer and dictate an application structure. Trust me, productivity in these environments was leaps and bounds better than the old way. The emergence of Visual Basic and Delphi in the early 90s were just a sign that programmers were getting a handle on how to write GUI applications

I think we are seeing the same transition now in the web application space. Web MVC brings a standard structure to web applications, and in a way, once again takes over the OS event interface for web applications. In 2007, writing a web application without an MVC framework will seem as quaint and be as rare as a polling event loop is today in a GUI application. The emergence of web MVC frameworks is a sign that we as a profession are mastering the art of building web applications.

Filed Under

  • PHP, Software Design

Related Posts

  • No related posts
You can leave a response, or trackback from your own site.

17 Responses to “The value of MVC”

  1. Ask Derek Scruggs » MVC and PHP Fusebox says:
    12/10/2004 at 6:14 pm

    [...] nce @ 12:14 pm Permalink

    I’ve been following Jeff Moore’s comments about Model View Controller (MVC) and the resulting discussion because [...]

  2. perrick says:
    11/29/2004 at 4:05 am

    Except it will not come from Stuts : Ruby on Rails is my first clue ! And it probably won’t be called MVC but just “WebApp Framework”.

  3. dv says:
    11/29/2004 at 6:30 am

    energy follows the path of least resistence. MVC is not that path.

  4. James Stewart says:
    11/29/2004 at 8:06 am

    I’m fairly new to formalised thinking on design patterns and have been following these discussions as best I can. My only exposure to MVC has been through learning Cocoa (an ongoing process) and I’ve found the use of it there liberating. What I’ve not yet found is a truly compelling demonstration of how to apply MVC to web development or a good articulation of what degree of separation of the different layers “counts” as MVC.

    Reading this entry I’m left wondering the extent to which use of IDEs is responsible for the success of design patterns on more traditional platforms. For me, XCode has been my introduction to MVC. Or is it more about layers/libraries that we all use in common (Visual Basic libraries, Cocoa, etc)? If the latter, how close are we to having the required libraries, and should we be looking for something that is PHP-specific or a broader platform that can be utilised from (almost) any language?

  5. Jeff Moore says:
    11/29/2004 at 12:13 pm

    Maybe it will be called WACT. :)

    The point that I was trying to make by linking to the Java framework comparison was that it would seem that even a confusing, crufty MVC framework is better than no framework. MVC frameworks in PHP are very immature and behind the state of the art in Java. Struts 1.0 was released in June 2001 and been actively developed far longer than any PHP equivalent.

    The path of least resistance is to use an existing, mature MVC framework and NOT to try and implement it yourself. Then, you can stop worrying so much about what goes where and just use the structure and components provided for you. When PHP MVC frameworks are mature, they will be the path of least resistence.

    Regarding the impact of IDEs, there is an interesting post making the rounds right now: The IDE divide (language vs IDE).

    I am very impressed with Cocoa and Objective C. In many ways, I think that Objective C’s dynamic nature and Cocoa’s maturity make it a better role model for PHP than the younger statically typed java.

  6. Derek Scruggs says:
    12/10/2004 at 11:52 am

    I started to post a comment, but it got really long, so now it’s here: http://www.askderekscruggs.com/mvc-and-php-fusebox.html

    I would’ve posted a trackback but didn’t see a trackback url in your post.

  7. Professional PHP » Blog Archive » Why isn’t PHP the natural successor to Java? says:
    9/29/2005 at 10:48 am

    [...] No mature frameworks – Ruby has been around a long time, but didn’t really start gulping mindshare until Rails came along. See The Value of MVC. [...]

  8. PHP Framework Consolidation? | Professional PHP says:
    11/27/2005 at 8:56 pm

    [...] As I suggested in The Value of MVC, the science of writing web applications is maturing and we are entering the age of frameworks. [...]

  9. The rumors of PEAR’s demise are greatly exaggerated | Professional PHP says:
    12/1/2005 at 9:51 pm

    [...] What is a framework? I wrote a little bit about this in The value of MVC, but according the the GOF: A Framework is a set of cooporating classes that make up a reusable design for a specific class of software. … [...]

  10. SitePoint Blogs » MVC and web apps: oil and water says:
    12/22/2005 at 4:38 am

    [...] So have we asked enough questions or have we just jumped on a collective bandwagon? Jeff in fact states the bandwagon factor clearly in the value of MVC—that there must be “something” in MVC because of demand for struts developers. [...]

  11. Some Links about MVC in Web Development - Stefan Fischerländer’s Blog says:
    6/7/2007 at 3:26 am

    [...] The Value of MVC [...]

  12. อะไหล่แอร์ says:
    4/23/2008 at 11:40 pm

    the MVC i love forever is cakephp

  13. Vulchak says:
    5/5/2008 at 7:40 pm

    Of course, but what do you think about that?,

  14. Joe says:
    9/19/2008 at 10:40 pm

    MVC or similarly modeled frameworks are the only way to fly when it comes to web development, especially in PHP. However, if you’re looking to actually get serious about decreasing your development time and increasing feature sets with minimal effort, you’ll ditch cake for Fuse.

  15. jm says:
    1/6/2010 at 7:39 am

    Well, it’s 2010, and you’re wrong about the absence of MVC in web design being quaint. MVC just doesn’t apply to the web, and anyone who tells you otherwise has redefined the meaning of MVC.

  16. puma sneakers says:
    6/15/2010 at 1:30 pm

    Yo this is nice. If any ya’ll interested, check out my recent remix of Heartless..

  17. angular cheilitis says:
    8/6/2010 at 2:00 pm

    I’m thinking that Fuse is the way of the future.

Leave a Reply

Click here to cancel reply.

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

code: use [code=php][/code].

Comment Preview

    Subscribe Feed
    Share Subscribe to this blog…
    Share Bookmark or share this page…
  • About

    My name is Jeff Moore. I'm a PHP programmer living in San Francico and working for a startup.

    More about me…

  • Categories (Home)

    • Agile Methods (14)
    • Mac (14)
    • Misc (17)
    • Open Source (14)
    • PHP (98)
    • Software Design (29)
    • Usability (14)
    • Web Design (20)
  • Recent Comments

    • Programming Language Trends via Google  19
      Craigslist pva, jessica, Scott [...]
    • Looking Towards the Cloud  35
      bentonville multiple listing, cosmetic dental, Sam Brodish [...]
    • PHP versus ASP  8
      Marhta Blight, Ravi, Ryan Brooks [...]
    • How to Transfer Mac OS X Application Data between Computers  59
      Website Migration, harry the computer support guy, Dotty Salvage [...]
    • Working with PHP 5 in Mac OS X 10.5 (Leopard)  157
      lehuuphuc, Robert Parthemer, Lingerie Intimate [...]
    • PHP Games  25
      jessica, Tennille Cranor at Chilli Plants, Lucas Ortell [...]
    • un-PEAR-ing  5
      jessica, Eugene Panin, Arnaud [...]
    • The Legality of Republishing RSS Feeds  23
      kevinxiao, Marissa Miscovich, Quick Student Loans [...]
    • Faster Page Loading  4
      jessica, angular cheilitis, Aaron Rosenfeld [...]
    • PDO versus MDB2  15
      jessica, kevinxiao, Gavin [...]
  • Recent Posts

    • ZendCon: Writing Maintainable PHP Code
    • Looking Towards the Cloud
    • Holiday Tech Support
    • Closures are coming to PHP
    • php | tek Wrapup
    • php | tek 2008
    • Sarah Snow Stever
    • Benchmarking PHP’s Magic Methods
    • The Endpoints of the Scale of Stupidity on Video
    • Working with PHP 5 in Mac OS X 10.5 (Leopard)
  • Site

    • Archives
    • Log in
  • Search