CSC/ECE 517 Fall 2007/wiki2 3 bp: Difference between revisions
No edit summary |
No edit summary |
||
Line 14: | Line 14: | ||
== introductory sites == | == introductory sites == | ||
http://www.mercurytide.co.uk/whitepapers/separating-structure-presentation-and-behaviour/ | http://www.mercurytide.co.uk/whitepapers/separating-structure-presentation-and-behaviour/ |
Revision as of 06:33, 21 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
http://www.devarticles.com/c/a/Ruby-on-Rails/Getting-Started-with-Ruby-on-Rails/2/
http://www-128.ibm.com/developerworks/linux/library/l-rubyrails/
http://www.webmonkey.com/05/28/index4a.html
http://instantrails.rubyforge.org/wiki/wiki.pl
http://www.sitepoint.com/article/ruby-on-rails
mvc in java - general
http://www.articlegold.com/Article/Simple-J2EE-Model-View-Controller-Type-II-Framework/6091
http://www.informit.com/guides/content.aspx?g=java&seqNum=117
http://www.oracle.com/technology/sample_code/tech/java/jsps/ojsp/mvc.html
http://javadude.com/articles/vaddmvc2/mvc2.html
http://www.leepoint.net/notes-java/GUI/structure/40mvc.html
http://www.javaworld.com/javaworld/jw-12-1999/jw-12-ssj-jspmvc.html
http://www.uta.fi/~jl/pguibook/mvc.html
http://www.csis.pace.edu/~bergin/papers/ModelViewController.html
mvc in java - struts
http://www.ibm.com/developerworks/web/library/j-struts/
http://www.theserverside.com/tt/articles/content/StrutsFastTrack/StrutsFastTrack.pdf
http://struts.apache.org/1.x/userGuide/introduction.html
http://struts.javabeat.net/tutorials/1-introduction-to-the-apache-struts.php
http://www.roseindia.net/struts/strutsguide.shtml
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.