views:

77

answers:

3

Hi,

My question is regarding design patterns, why most of the Web Applications currently employs Model-View-Controller Design Patterns as compared to other Design Patterns ?

Thanks.

A: 

Well, almost all languages support it - it is a well known, easily recognized and well understood design pattern that fits into the paradigm of most web applications. In some cases, it may be overused - but generally it is a good choice for web applications - which are generally just glorified CRUD (Create/Read/Update/Delete) database front ends.

Shane C. Mason
+2  A: 

The MVC pattern lends itself naturally to the core of what the Web frameworks provides:

  • You often have to serve data from your backend (Model)
  • Content needs to be rendered (View)
  • Requests need to be handled and routed (Controller)

and keeping these concerns separate and not intertwined. It is often tempting to mix these concepts (e.g. SQL calls within a JSP/ASP page), which leads to maintenance problems. MVC helps to prevent that and put some structure into the overall web application.

Of course, other design patterns can still be used in the web application, but MVC fits the Web Framework's "serving of backend data" scheme, very well.

EDIT: as RibaldEddie points out: MVC is not just the separation of these concerns, but how the framework allows them to interact cleanly. Of course, there's more to the MVC pattern, this is not an exhaustive explanation of the pattern.

pythonquick
So you're saying that a "design pattern" only contains nouns? You've listed the nouns but haven't at all discussed the verbs; that is, how do those three things work together? That's the important part. That's where the developer's hard work is, and that's where you make or break the maintainability of the application. It's not the parts, it's how you wire them together!
RibaldEddie
@RibaldEddie: good point, I added an edit to make that clearer.
pythonquick
+1  A: 

It's just a name taken from an older generation of paradigms for OOP GUI software development.

It's a name that was chosen for the web because back in the day when the web wasn't the focus for software development, MVC was how you could separate your concerns (or more accurately, encapsulate what varied).

Since people have had a real problem separating their concerns in the early days of the web, they used this name from desktop application programming to convince web developers that there is a better way.

Unfortunately, in my view, we have lost a little bit of what made MVC so powerful on the web. There are a lot of programmers who have only had experience with the web and its notion of MVC. I think if you look at some of the older desktop libraries you may find a new way of looking at the old notion of MVC. Hopefully that will give you an idea of where the really nasty problems live when it comes to architecting for the web.

RibaldEddie