views:

94

answers:

2

I am (as I'm sure many of you are) pretty familiar with Rails' MVC design pattern as well as Django (and others') MTV design patter. I was wondering what other patterns other frameworks use for web application development. What are their strengths/weaknesses?

thanks

A: 

MTV is just a more accurate name for what's usually called MVC. So in fact, Rails and Django use the same pattern. Is has established over years and hardly any framework does things differently, except maybe the half-object pattern. However, halb-objects have not established in the web world.

The "real" MVC is a pattern found in classical GUIs as well as within JavaScript (if you only look at what's happening within the browser). It is simply not applicable in the WWW so it had to be adapted. The result is confusingly often also called MVC, while MTV is a more accurate description.

vog
MVC for the web should be simpler, there is no need for a listening, the web server does that, and the request is the event. There is no need for another design pattern. MVC for the web essentially boils down a concrete instance of the mediator pattern, with the controller mediating between the view and the model.
George Jempty
In contrast to MVC, the web version needs to create GUIs using templates on each action. This is not necessary in classical GUIs. Hence, there are two major differences in the web, and the notion of "View" and its interactions with the other parts (model, controller) changes dramatically. That's why a new name such as MTV is appropriate.
vog
PS....I've implemented "real" MVC in Javascript, and it does *not* just come "out of the box" as you imply. You create your listener, then widgets register to be notified of events. It lets you keep you Ajax-enabled widgets in synch, for instance when you add a comment, your widget that displays the number of comments can additionally be updated.
George Jempty
MVC is a good description of what's happening within sole JavaScript (without server requests). It is structured the same way as e.g. Qt or GTK+. This is original, plain MVC. However, if you add server requests (AJAX, etc.) and run the main part of your application on it, its a whole different story.
vog
A: 

My miniature (60-line) MVC engine for PHP, http://code.google.com/p/barebonesmvc-php/, used successfully on an embedded consumer device by Cisco, relies on the "template method" pattern, wherein the parent class specifies the steps to an algorithm but the child class is responsible for implementing some of those steps.

static function sendResponse(IBareBonesController $controller) {
      $controller->setMto($controller->applyRequestToModel());
      $controller->mto->applyModelToView();
}

In the case of my engine, the developer needs to implement applyRequestToModel. Not only Spring's Web/MVC module, but also my applyModelToView method, takes a map/hash/assoc-array and makes it available to the view, except Spring conflates the two facets of MVC in the name of their abstraction (ModelAndView), whereas my abstraction is more appropriately name ModelTransferObject (aka $mto).

Speaking of Spring, in the GoF reference regarding the template method pattern, the GoF refer to "inversion of control"

George Jempty
This is just MTV implemented using the strategy (aka "templated method") pattern. So yes, internally it uses another pattern, as every software uses internally more than one pattern, but at the whole it's still just MTV.
vog
Read your GoF, the Strategy and Template Method patterns are *not* the same. Related, yes, the same no.
George Jempty