views:

108

answers:

7

What are design patterns that would be useful for a web framework besides MVC, the Rails-induced frenzy? Not saying it's a bad thing, but it is now practically ubiquitous in web frameworks.

Ideally the pattern should make easier:

  • Separation of concerns
  • Modularity / reusability of code
  • Unit testing

What patterns fit the bill? Are there example of frameworks out that follow it?

+1  A: 

Have you looked at MVP?

It's a well-known alternative to MVC, and is covered in many of the "well-known" pattern books.

You can read here that Martin Fowler has actually split the MVP into two patterns.

Here is one MVP framework for PHP.

And here is one for .NET.

It's worth noting that the .NET guys responsible for MVC were also influenced by django, not just rails.

Joe R
A: 

Subject Observer pattern

Factory Pattern

Vinay
+3  A: 

MVC is not a Rails-induced frenzy. It goes back to Smalltalk. You can check out the history in the GoF book as well, which pre-dates Rails.

I don't know about patterns beyond the GoF book, but I'd say that general ideas of layering (e.g., separate web, service, and persistence tiers) and decomposition apply regardless.

duffymo
I know MVC predates Rails; but it wasn't until Rails that it became ubiquitous in web frameworks.
Confluence
Not true. It was there in Struts 1.
duffymo
A: 

Model-View-ViewModel (MVVM) might be worth looking into as its a newer pattern that is largely based on the Model-View-Controller (MVC) pattern your currently using.

Due to the seperation of layers it should lend itself nicely to making it reusable and well as being easy to apply unit testing to each part.

An exmaple of a framework can be found here. ASP.NET (MVVM)

kevchadders
A: 

The Lift web framework follows what its creators call View First.

Where this differs from MVC is that control is handled first by the view, not by a controller. The view may call logic in several snippets (the closest to an analogue of controllers).

I see this as an inversion of RESTful design, where URLs are mapped to resources, and views are a way of displaying these resources. In View First, URLs map to views, which may pull out and display any arbitrary collection of resources.

The reasoning behind this is that often, a page on a web site or application needs to display much more than simply the resource that was requested: it might have a list of recent blog comments, a 'shout box', et cetera. Other frameworks handle this by having secondary mechanisms for showing content and handling input (such as Django's template inclusion tags and middleware), and leaving the controller* to handle the primary resource that the page is displaying.

(* It's tricky to involve Django in discussions like this because essentially it is MVC, although for subtle reasons its creators use the terms Model-View-Template. Here, though, I will call Django's view a controller.)

Ben James
A: 

Naked Objects

http://www.nakedobjects.net/home/index.shtml

I should clarify that this uses MVC but in a very different way

msarchet
A: 

Although MVVM (or DM-V-VM) was already mentioned, there is a good series about it on the MSDN network (although it mainly concerns WPF). If you're looking for another DM-V-VM example, I happen to have written a PHP framework largely following the pattern.

Furthermore, I believe there are quite a lot of different interpretations of MVC in web application development. Just compare the ideas (regarding MVC) behind Apache Struts and CakePHP for instance. I haven't used RoR, but I would look further than just RoR to get a good view on MVC (again, in web app dev ;).

taitale