CSC/ECE 517 Fall 2007/wiki2 3 bp: Difference between revisions
No edit summary |
No edit summary |
||
Line 191: | Line 191: | ||
http://struts.apache.org/1.x/userGuide/introduction.html | http://struts.apache.org/1.x/userGuide/introduction.html | ||
This is the official documentation for the Apache Struts project. It is not structured as a tutorial, nor does it make for a good introduction to writing an MVC application using Struts. However, it is an excellent reference source for a developer working on a more in depth Struts application which goes beyond the simple examples provided in the other Struts guides. | |||
http://struts.javabeat.net/tutorials/1-introduction-to-the-apache-struts.php | http://struts.javabeat.net/tutorials/1-introduction-to-the-apache-struts.php | ||
A fine tutorial on the use of the Struts framework to implement an MVC application in Java, this page goes over the definition of MVC before launching into a discussion of the Struts framework. Finally it walks the reader through implementing an extensive sample application using Struts. Going beyond the typical hello world style application, the sample application used in this tutorial leverages some of the more complicated features of Struts including validation. | |||
Revision as of 03:47, 22 October 2007
Model-View-Controller Review of Resources
Written by Ben Parees
quick overview of mvc
The Model-View-Controller pattern, referred to as MVC in most literature, is a way of structuring code to achieve separation of concerns. In this case, the three concerns are managing the physical data, representing the data to the user, and tying the representation of the data to the physical data in such a way that it can be manipulated by the user. These three concerns are managed by:
The rest of this page provides links to websites which provide more in depth information describing MVC, examples of its usage, and specific tutorials for using MVC in Java and Ruby, along with reviews of those sites.
introductory sites
http://www.mercurytide.co.uk/whitepapers/separating-structure-presentation-and-behaviour/ Starting approximately 1/3 of the way down the page, this website gives the classic definitions of model, view, and controller. In addition, it provides a short discussion on the advantages of the MVC approach. Finally, it provides a short example of how to separate a web page into the view (done in xhtml) and the controller (done in javascript). This example is not fully fleshed out and thus not paticularly useful as a starting point for someone implementing MVC on their own, but it provides a good demonstration of what sort of things belong in the controller and which belong in the view. This lends a certain concreteness to the concepts described in the MVC definition section of the page.
http://struts.javabeat.net/tutorials/
This website provides a very short overview of MVC by defining model, view, and controller. It is a somewhat Struts centric, providing examples of how Struts components fulfill each of the MVC roles, however the definitions are general to MVC as a whole. The bottom of the page contains a useful diagram of the MVC components. Although this diagram is labeled in terms of Struts components, it is easily comprehended even by a user who is not implementing the MVC pattern using Struts. (See the Implementing MVC in Java section for web pages which discuss Struts in depth).
http://en.wikipedia.org/wiki/Model-view-controller The canonical source for MVC definition, the Wikipedia page provides not only a good overview of the MVC concepts, but also some history about the origins of MVC. It also provides a discussion of how MVC is implemented in various programming languages including a discussion of both traditional GUI frameworks and the more modern web-based frameworks. While this information is not detailed enough to guide a user to implement an MVC style application in any of these languages, it provides some good fundamental information about how each of the MVC pieces are represented by library components in various languages including Java and .NET. This site also provides a fairly complete list of known MVC framework implementations which users might wish to leverage when implementing their own MVC based application, though no information is provided about how to use these frameworks or what the pros and cons of each might be.
http://hubpages.com/hub/MVC This site provides the standard definition of the MVC components along with a short discussion of the advantages of the MVC structure, with an emphasis on the idea of having multiple views of the model data. This site does not offer any special insight into MVC, but if one is just looking for a quick overview of what the MVC concept is, it can be found here.
http://doc.trolltech.com/4.3/model-view-introduction.html Though primarily intended as a guide to using the MVC framework provided in the Qt library, the first half of this page provides the usual definition of Models, Views, and Controllers which are general enough to be of use to anyone trying to understand the basic concepts.
http://www.indiawebdevelopers.com/technology/java/mvcarchitecture.asp This page offers a solid definition of MVC, within the context of software design patterns in general. This is particularly elegant since it discusses not only the advantages of MVC itself, but the advantages of using any design pattern. The definition itself is particularly thorough, describing some of the actual mechanics involved in performing the Model, View, and Controller tasks. Finally it concludes with a short discussion on the advantages of the MVC approach which is lacking in some of the other literature on MVC.
http://www.perlmonks.org/?node_id=402070 Though located on a perl specific website, this article itself largely avoids specific references to Perl, making the content suitable for anyone seeking an introduction to the MVC pattern. The article provides a very high level discussion of the MVC components. Unfortunately it does not provide any sort of concrete example of how to apply MVC to solve a real world problem. It does include an interesting diagram showing the communication flow between a browser session and an MVC framework which is useful to the novice to understand what goes on in a web based MVC application. Lastly, this site includes not only a discussion of the advantages of MVC, but a list of the limitations and pitfalls of MVC. This is perhaps what makes this article stand out from the others, as no other site reviewed included any acknowledgment of potential issues with implementing an MVC solution.
http://msdn2.microsoft.com/en-us/library/ms978748.aspx
This site is notable because of the way in which it sets up the discussion of MVC. Rather than immediately launching into a definition of the MVC components, it starts out with the problem to be solved and a discussion of why traditional solutions result in difficulties maintaining code, or in applications that perform poorly. This sets up the motivation for the MVC concept. It then goes on to introduce the MVC pattern as a solution to these problems and includes a very in depth discussion of the MVC philosophy and how it addresses the concerns raised earlier. It also includes some interesting variants on the traditional MVC interaction.
http://www.adobe.com/devnet/flash/articles/mv_controller/as2ess_ch18.pdf Actually a chapter from a book which is available online, the first half of this pdf file provides the most in depth discussion of what MVC is of all of the sites reviewed on this page. Professionally written, this very detailed overview includes flow diagrams of what happens when a user interacts with an MVC application, how responsibility is delegated to each aspect of the MVC framework, and motivates it all with a real world example of a Clock application. If one wants to truly understand the structure of the MVC pattern, including UML diagrams of the component pieces, this is the page to view.
http://www.mobilefish.com/popupwindow/mvc_song.html
Included mainly for completeness and humor value, this page sets a loose description of MVC to lyrical form, including a downloadable mp3 version of the MVC song. Though not useful as a primary source for someone just starting to learn what MVC is about, someone with a basic grasp of the MVC concepts might find a few interesting tidbits about the value and application of MVC hidden within the lyrics of this song.
http://ootips.org/mvc-pattern.html
Another classic definition of MVC. This page does not provide a particularly outstanding definition of MVC, but it is serviceable as a basic introduction to the MVC concepts. The page does provide a valuable diagram of the Model/View/Controller interaction.
http://c2.com/cgi/wiki?ModelViewController This site provides a large collection of individual short summaries about what MVC is and is not. The value of each of these summaries varies greatly but at least a few of them provided some interesting insights into the MVC concept. This site should definitely not be used as a primary introduction to what MVC is, but once the reader has a reasonable grasp on the MVC concepts, they are likely to find a few nuggets here that lead to a deeper understanding of the true power and intent of the MVC architecture.
http://www.themolehill.com/index.php/2006/07/29/beginners-guide-model-view-controller-mvc-architecture/
Nestled in the middle of a tutorial about Ruby on Rails, this article diverges into a typical discussion of what MVC is all about. The definitions in this page are resoundingly average, providing a perfectly adequate overview of what each component is and how they interact but without providing any sort of example to cement the concepts for the user. Worth reading for a quick, easy to understand discussion of what MVC is, but this page should only be used to provide a general background understanding before moving on to deeper discussions of the inner workings of MVC. Worthy of note are the "bottom line" comments by the author which sum up each of the MVC components in a single line which describes what that component does.
http://best-practice-software-engineering.ifs.tuwien.ac.at/patterns/mvc.html Though not notable for its definition of MVC itself, this page provides the best diagram of MVC in operation of any page I found. The diagram at the top of this page provides a perfect representation of the interaction and invocation of each component in an MVC application, including the role of the user. Once the reader has familiarized themselves with the definition and intent of MVC via some of the other pages, the diagram here will provide an excellent visualization of how the pieces fit together in an application. However, this page should not be used as a starting point to develop an understanding of MVC.
http://slash7.com/articles/2005/2/22/mvc-the-most-vexing-conundrum
The most informal overview of MVC (other than the MVC song, perhaps), this page discusses all the components of MVC in a very thorough, if lighthearted, manner. Whether this page should be used as a starting point for understanding MVC largely depends on the attitude of the reader. Someone looking for a no nonsense nuts and bolts overview of MVC will probably be put off by the style of this page. However, someone looking for something more than the standard dry definitions of MVC might find tihs page a bit easier to consume. The content itself is impeccable, regardless of the reader's preferences regarding writing style. This site also ties the MVC discussion back to Ruby on Rails, but the discussion of Rails is so minimal as to not be very useful to someone coming up to speed on that topic. As such, this page should only be used as an introduction to MVC and not as an introduction to MVC on Ruby/Rails.
http://orderedlist.com/articles/rails-and-mvc Another page which purports to be discussing Ruby on Rails, but really only discusses MVC in very general terms. Still, when taken as such, this page provides a nice quick summary of Models, Views, and Controllers. In addition it provides a few guidelines about what sort of content should be in each component and how to tell if you are trying to do unnatural things in one of your components. Overall this site provides high quality definitions of MVC, and the generalized implementation guidelines are a nice touch for someone who is trying to understand in more concrete terms how to structure their MVC application.
example sites
This set of web sites provide good demonstrations of how to map an MVC solution onto a real world problem. They are not sites which provide good example code to someone looking to implement an MVC solution in a particular language. Instead, they are sites that provide good examples of how to break a real world scenario into the Model, View, and Controller components and what tasks should be delegated to each component.
http://developer.apple.com/documentation/Cocoa/Conceptual/ObjCTutorial/chapter02/chapter_2_section_3.html This site provides some of the cleanest MVC diagrams of all the sites reviewed. In addition to having a solid discussion of the MVC terminology, it provides a concrete example of a currency converter application with a discussion of how each piece of this application maps to each of the MVC components. Again diagrams of the components are provided along with very easy to read descriptions of the components.
http://www.adobe.com/devnet/flash/articles/mv_controller/as2ess_ch18.pdf Though already linked above in the list of sites which provide quality overviews of MVC, this page is also worthy of note for its excellent example application. Although the implementation is done in ActionScript, the exercise of defining how a Clock application can be implemented in MVC to easily provide different ways of viewing and managing the current time while separating the code into easily modified independent components is general enough that it is worth reading. Even if the reader has no experience or interest in ActionScript, the code can be interpreted as pseudocode and the reader will still find the information worthwhile in terms of demonstrating how to break a problem down into traditional MVC components.
http://www.practicalecommerce.com/blogs/developers-diary/archives/92 Though this article appears to be intended to describe what MVC is, it falls short of that goal by launching too soon into a discussion of how to apply MVC to a simple application. That leaves this page best used as a secondary source after the reader has become familiar with the MVC components. However, once the reader has that background, this site provides an excellent discussion of how to breakdown a common problem (an application backed by database storage) into Model, View, and Controller components.
http://java.sun.com/blueprints/patterns/MVC.html
This page breaks down a "Pet Store" application into various logical components and labels each of them as Models, Views, or Controllers. This is a solid example of how to apply the MVC structure to a real world concept and should really help users see how to break their own problem down into constituent MVC components.
http://java.sun.com/blueprints/patterns/MVC-detailed.html
Though this site stops short of fully resolving a real world problem into MVC components, it provides a solid example of how the View component can be used to provide a rich variety of application interfaces. A very readable diagram provides a demonstration of how multiple views can be used to provide the same content to a variety of users regardless of what their interface to the system is.
http://www.codersource.net/aspnet_model_view_controller_sample.html This page provides a nuts and bolts example of implementing an application using MVC. Although the language used is ASP.NET, the structure of the code is universally applicable. One particularly valuable detail in this page is that the author first develops the sample application without using MVC, and then rewrites the application to leverage the MVC separation of concerns. This provides a powerful demonstration not only of how to break a problem down into its MVC components, but also what value is derived from doing so.
http://www.enode.com/x/markup/tutorial/mvc.html
The example presented on this page is of particular note because rather than focusing on applying MVC at a macro level to large application implementation, the author instead focuses on a single GUI widget. This demonstrates to the reader that MVC is not just a pattern to be applied to the application structure as a whole, but is also a concept which should be applied to any piece of data which is maintained by the system but interacted with by the user. The example is nicely complemented by quality illustrations to allow for easy comprehension of the concepts being discussed.
http://www.csis.pace.edu/~bergin/mvc/mvcgui.html
Another non-web based example of using MVC, this page applies MVC to a thermostat controlling GUI. The example is well developed, with the author adding incremental complexity in order to show the true power of MVC in terms of making it easy to extend and enhance an application without breaking existing functionality or changing existing pieces of the application. The example is implemented (with source code provided) in Java, which is particularly beneficial as the majority of readers are likely to be able to easily follow and perhaps even compile and run the sample application.
http://www.developer.com/java/ent/article.php/3336761 This page is of particular value because it describes how MVC is applied to a set of libraries which have probably been used by most readers without them even realizing they were leveraging MVC. The article discusses how the Java Swing GUI framework is implemented using MVC concepts. This provides readers with a way to associate the MVC way of thinking with code they may have already written, allowing for a natural bridge from concepts they were already familiar with using, into creating their own MVC architectures for new applications.
http://www.slideshare.net/codeinmotion/mvc-demystified-essence-of-ruby-on-rails
Starting on slide 16, this presentation on MVC uses the real world example of a bakery to demonstrate how the MVC components can be applied. Of the examples cited on this page, tihs one is the most accessible due to its reliance on purely real world concepts rather than any actual code or implementation details. The example provides a very natural way to think about MVC and encourages the reader to see that anything can be defined in terms of Models, Views, and Controllers.
how to build an mvc application
mvc in ruby - rails
http://www.onlamp.com/pub/a/onlamp/2006/12/14/revisiting-ruby-on-rails-revisited.html The classic starting point for learning Ruby on Rails. This tutorial goes through installing Ruby, Rails, and everything else needed to create a Rails project from the ground up. At the conclusion of this article, a full MVC application has been created utilizing the Rails framework, making this site the perfect starting point for someone looking to implement MVC in Ruby.
http://www.devarticles.com/c/a/Ruby-on-Rails/Getting-Started-with-Ruby-on-Rails/2/
Another good site for creating a Rails application, this page goes through creating the component pieces (Model, View, Controller) of a trivial MVC application. This article is a fine starting point for someone looking to become familiar with how to write an MVC application using the Ruby on Rails framework.
http://www-128.ibm.com/developerworks/linux/library/l-rubyrails/
Perhaps the best of the Ruby-based MVC tutorials in this list, this page guides the reader through creating a Phonebook application using the Rails MVC framework. This guide is extremely detailed providing step by step instructions and then providing archived versions of the code for download at the end of the article. One thing this page does not provide is information about creating a Ruby on Rails development environment in the first place. For this, readers should review the "Revisiting Ruby on Rails Revisited" article.
http://www.webmonkey.com/05/28/index4a.html Another good site for learning how to create a basic Ruby on Rails application. This page also does not describe how to setup the Rails framework itself, but it does contain references to pages which do offer this information. The application tutorial itself is fairly simple, giving the user a quick "gee-whiz" reaction to show how easy it is to make Rails do something, but stops short of going into significant detail on how to customize the application or do moderately complex operations.
http://www.rails4days.pwp.blueyonder.co.uk/Rails4Days.pdf The most in depth tutorial on the list, this article advises a timeframe of four days to complete the tasks it lays out. These tasks take a new user from the ground up to implementing a full fledged Ruby on Rails MVC application. This includes getting the prerequisite software. The application implemented in this tutorial is a todo list application which makes good use of the supporting database concepts implemented by the Model as well as traditional html based Views. Though a bit intimidating because of its length, this is the most complete tutorial on creating a new Ruby on Rails application.
http://www.sitepoint.com/article/ruby-on-rails This is an excellent article which takes the reader from "what is ruby" through MVC and Rails before culminating in a Rails-based application implementation. This article covers installation of the required components in addition to providing the code to implement the sample application and providing some basic instruction on Ruby syntax.
http://instantrails.rubyforge.org/wiki/wiki.pl While not an actual tutorial, this site offers one stop shopping for getting a Ruby on Rails development environment and server up and running. InstantRails provides a solid foundational point for following one of the other application development tutorials since it ensures the reader has all the basic components (Ruby, Rails, database server, http server) needed to start doing Ruby on Rails development.
mvc in java - general
http://www.articlegold.com/Article/Simple-J2EE-Model-View-Controller-Type-II-Framework/6091 This article takes a truly generic approach to implementing MVC with Java. Rather than showing the reader how to implement a sample application using an existing Java-based MVC framework such as Struts, it implements its own MVC framework and then produces a sample application to run on top of that. While this is probably overkill for most users who would rather learn to build an application on top of a more widely used MVC framework, this approach offers a great deal of flexibility in showing the reader how to implement MVC in the absence of any assumed framework support.
http://www.informit.com/guides/content.aspx?g=java&seqNum=117
This is another article which approaches using MVC in Java without assuming any specific MVC framework. Instead, it shows how to implement a simple MVC architected application using traditional JSP/Servlet components. To make the MVC association clear, it labels the components as controllers, views, etc, but it does not rely on anything beyond typical Java/J2EE components as it shows the user how to implement an MVC application in Java.
http://www.oracle.com/technology/sample_code/tech/java/jsps/ojsp/mvc.html
This article offers a fully implemented sample application which leverages the MVC architecture using JSP components in Java. Although the article does not walk the user through the application with any great detail, it provides fully runnable source which an intermediate user could take and rework to implement their own MVC application in Java.
http://javadude.com/articles/vaddmvc2/mvc2.html
One of the few articles which implements a non-web-based MVC architecture in Java. This article shows how to apply MVC concepts to a typical Java GUI application. The article is extremely detailed, walking the user through the code with great care, ensuring that the reader should be able to apply the MVC techniques to their own Java application.
http://www.leepoint.net/notes-java/GUI/structure/40mvc.html
This is another article which teaches the reader how to implement MVC in a standard Java GUI application. In this case, a calculator application is implemented using MVC concepts. Again, no specific MVC framework libraries are required, instead the article focuses on how to structure standalone objects in the role of Models, Views, and Controllers. An excellent article for someone looking to see how to apply MVC to their day to day Java code.
http://www.javaworld.com/javaworld/jw-12-1999/jw-12-ssj-jspmvc.html A more technical article aimed at people who already have a solid JSP/Servlet background. This article describes Java's Model 2 architecture which is in effect, MVC. The article implements an example shopping cart application using Model/View/Controller components. Again, no framework is required as the MVC logic is simply built into the application itself. This makes the example bulkier, but provides the reader with a more in depth understanding of how to implement MVC on their own without needing to rely on a framework which might or might not be appropriate to their deployment environment.
http://www.uta.fi/~jl/pguibook/mvc.html This fairly short web page discusses MVC in terms of the Java Observer/Observable pattern. Though it doesn't provide a concrete example application, it shows a rough skeleton of how to implement the Model/View/Controller components in Java using Observers/Observables. This is applicable to Java GUI applications rather than web-based applications, so readers looking to implement standalone Java GUIs would do well to read this guide in order to learn how to implement MVC in their Java application.
mvc in java - struts
http://www.ibm.com/developerworks/web/library/j-struts/ This tutorial takes the user through implementing a simple mailing list application using the Struts framework. In order to enhance the value of this tutorial, it starts by implementing the application in a non-MVC style. It then shows how to restructure the application to leverage MVC via the Struts framework.
http://www.theserverside.com/tt/articles/content/StrutsFastTrack/StrutsFastTrack.pdf This article gives an extremely in depth discussion of the Struts framework. Though likely to be intimidating to a new user, this is a logical next step for someone who's seen a simple example Struts application implementation. This article discusses the entire Struts API as it applies to the MVC pattern. However, it does not provide any sample implementation of an application, so it is best used as a reference source for understanding some of the other Struts-based example applications reviewed.
http://struts.apache.org/1.x/userGuide/introduction.html
This is the official documentation for the Apache Struts project. It is not structured as a tutorial, nor does it make for a good introduction to writing an MVC application using Struts. However, it is an excellent reference source for a developer working on a more in depth Struts application which goes beyond the simple examples provided in the other Struts guides.
http://struts.javabeat.net/tutorials/1-introduction-to-the-apache-struts.php
A fine tutorial on the use of the Struts framework to implement an MVC application in Java, this page goes over the definition of MVC before launching into a discussion of the Struts framework. Finally it walks the reader through implementing an extensive sample application using Struts. Going beyond the typical hello world style application, the sample application used in this tutorial leverages some of the more complicated features of Struts including validation.
additional references
Model/view/controller. There are literally hundreds of pages describing MVC on the Web. If someone wants to learn about it, what should (s)he do? Look at the first few hits in Google? I expect we can do better than that. Write a review of the MVC sites on the Web. Which are best for learning about the concept? Which have the most instructive examples? Which are best for explaining how to use the pattern in Ruby and Java? If you choose this topic, you should be sure to peruse at least several dozen sites.