Home About The Codist RSS Feed

Not Quite Your Grandma's MVC Pattern
Feb 28, 2007 08:44 perm link Readers: 882

Model-view-controller (MVC) is an architectural pattern used in software engineering. This dry sentence begins the Wikipedia article on MVC. MVC is the foundation pattern of most modern application frameworks, especially on the web.

I have always had a bit of a beef about the description. In my mind, the pattern is really M-V-A-C, as in Model, View, Action, Controller. Maybe this is splitting hairs but to me it matters; the controller should not update the model directly. There is a need to decouple the driver of the application from its data.

If you examine many MVC web frameworks, you actually see this in practice. In HTTP you have two connections between the "application" and the "user", a request, and a response. Generally there are also two kinds of requests, GET and POST. A GET request asks the application to respond with a view of some data from the model. A POST request asks the application to do something, which usually involves updating the model and responding with a new or updated view. Note the bolded words.

In a tradional view of this pattern, the controller is usually assumed to update the model directly, then respond with a new or updated view of its choosing. In practice the act of updating the model is usually handed to an action, which may also first perform any validation either directly or indirectly (depending on the framework). The success or failure of the action then prompts the controller to return a view.

So in my view the pattern is really this:

The view is basically the reader of the model, and the action is the writer. The controller does not directly access the model.

None of this is really new, as in practice most MVC frameworks work this way, but the typical description always seemed to be missing the crucial detail A.

My Tags:

  • assaf: Feb 28, 2007 23:08

    It's wikipedia baby. Edit!

  • Antonio Goncalves: Mar 01, 2007 02:04

    I completly agree. When I started using Struts years ago I had the same question : "if the controller is the Struts servlet, what the hell is the action?". Same thing with JSF and other web frameworks (I don't know Spring MVC but). But because Controllers are hidden in these "modern" web frameworks and we don't use them directly (except throuh XML for configuration), we could even call the patter (M)odel (V)iew (A)ction and dump the (C)ontroller.

  • Add Comment

Info
Nov 09, 2006 09:25 perm link Readers: 4277

I am a programmer with 25 years of professional experience.

My first exposure to programming was in high school on a 110-baud teletype connected to a Basic timesharing system, using paper tape to store programs. My first complete program was a carnival - simple games like tic-tac-to and a spinning wheel, all running line by line of course.

How far we have come.

LinkedIn Profile

Contact me: codistconsulting at gmail dot com.

Partial Resume:

  • Development of custom java web framework and CMS(Java, H2, IBatis, Jetty)
  • Development of custom java web framework for digital printing company(Java)
  • Ajax development of production control system UI(Java)
  • Company Directories project utilizing Documentum (Java, DFC, AJAX)
  • Agent Web project utilizing Documentum (Java, DFC)
  • Documentum team leader
  • Development of standard company software architecture based on BEA Portal
  • Wrote calendar, scheduling and logging web application for the Business Services Department. Wrote CSS based front end, business logic and database design. (Java, JSP/Tomcat, SQL)
  • Development of a DAO, EJB CMP and ADO.NET data persistence code generator for relational database systems. This consisted of a Swing front end application to manage the database model and all user settings for each of the different data persistence targets. A built-in code/xml generator created the Java source or XML files necessary for each target. (Java Swing, SQL, JDBC, project lead)
  • ActivePort: Development of an XML based data conversion suite to facilitate integration of enterprise software systems though messaging middleware and a scripting environment. Users could write plug-ins for enterprise application that would take data in the native format, convert it to an xml message, send it through ActivePort where it would be converted to an outgoing XML format and sent to a target application. The conversion process and flow was managed by a scripting language and XML mapping technology. This product ran under WebLogic and JBoss (Java, J2EE, XML )
  • Arkionet: Catalog management software for a construction supply company's website. This site used elements of IBM Websphere Commerce server, but required a lot of customized functionality. Data conversion from the existing JD Edwards system required a lot of conversion software which needed to handle large complex raw data to be compatible with the WCS database. (Java, JDBC, SQL, Websphere Commerce Server)
  • Prototype of a combined airfare/hotel/car rental itinerary pricing system. (Java)
  • Sabre Prometheus: initial development and architecture of a high speed distributed application to integrate Sabre Reservation System and external information sources. The system would integrate data from external fare sources (such as Airline web fares) into the Sabre Reservation System to allow agents to include non-Sabre fares in their searches. (Java, J2EE, JMS)
  • Sabre Snap! Online: analyzed Air Pricing group business processes, designed and coded a web based application for travel agencies to enter and manage pricing information and a web based workflow system for Air Pricing analysts to process it, collect statistics and generate reports (Java, J2EE, Weblogic, JSP, Project Manager)
  • DMS Surveyor: developed online and phone customer survey system's script language interpreter (Java)
  • Nursing Hands: led team in developing online health information site (Webobjects, Java, Project Manager)
  • Cheap Tickets Refunds: analyzed refund department business processes and then designed and developed a workflow system that lowered refund responses from 3 months to one week (WebObjects, Objective-C, SQL, Oracle, Project Manager)
  • Consumers Digest Online: developed cross-product search engine for CD Online which supported complex fuzzy searching across 50,000 product with sub-second response time. (WebObjects, Objective-C, C, SQL, Oracle)
  • US Postal Service Call Centers: developed web based application used daily by 40,000 post offices (WebObjects, Objective-C, SQL, Oracle, Project Manager)
  • Biit Inc: Developed HeapManager, a memory allocator and debugging library. Used by a large number of application developers (Mac, C++)
  • The SU5 Group Inc: Designed and developed Deltagraph, a charting application. Team leader assisting the development of Persuasion presentation application. (Mac, C)
  • Data Tailor Inc: Designed and developed Trapeze, a spreadsheet application (Mac, C)
  • General Dynamics: Developed communications software and software development tools (Various)

My Tags:

    Name:


    Optional URL:


    Comment:


    Save Cancel

    Copyright © 2007 By Andrew Wulf