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.