Http:/pg.ece.ncsu.edu/mediawiki/index.php/CSC/ECE 517 Fall 2007/wiki2 3 77

From Expertiza_Wiki
Jump to navigation Jump to search

Model/View/Controller Websites Overview

Topic


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.

Introduction to Model/View/Controller (MVC)


This is an architectural pattern adopted in software engineering. Generally, complex computer applications deal with large amount of data in conjunction with the functionality accessing this data. This generally becomes difficult to handle. Hence the programmer prefers to separate the functionality and data (model) from the user interface (view). This technique is very useful since any changes made to user interface may not affect the functionality of the program and vice versa. The data may be reorganized without making any changes in user interface. This is accomplished by decoupling data access from data presentation and user interface by the introduction of an intermediate component named controller.

The application is decoupled into three layers that would allow flexibility and reuse:

Model: This is the domain-specific representation of information where the application operates. It knows about all the operations that can be used to transform this information. But it has no idea how these operations are invoked.

Controller: This layer responds to the user (user inputs) which may invoke changes on the model. More specifically as mentioned by “Martin Fowler” in his book “Patterns of Enterprise Application Architecture” in a lucid way “Controller takes user input, manipulates the model and causes the view to update properly”

View: This layer provides the user interface element. This is the user-visible view of the model where the information is presented in a domain-specific and user-friendly way.

The MVC architectural pattern is very useful for the purpose of web development applications. One of the main purpose it serves is the separation of concerns. Hence, code is cleaner and easier to understand. The other advantage is reusability. The model can be enhanced in order to improve the functionality of the code with very minimal changes to the controller or view.


Categories of Websites

There are many sites available online about MVC which are very useful to a newbie. Certain websites provide proper pictorial representation and conceptual view of architectural pattern while some provide insight into the interaction between the different layers (i.e. model, controller and view). The websites can be categorized into two broad divisions, "Basic Concept", "Implementation-Specific" and "Examples :

"Basic Concept" Websites

Websites dealing with the concept of MVC as a design pattern :


"MVC Explained with an Example"

Any concept explained through an example is better understood than just theoretical description.Thus, while categorizing websites higher priority is given to those which explain MVC with an example.

Summary:This site provides the perfect place for a novice of MVC to start. This was written in a conversational style and easy to understand. As we proceed with the blue arrows provided on the right bottom corner or the right-top corner, the author slowly develops MVc concept and explains it through a very simple instructive example of "Heart-Beat".

Example: The heart-beat example consists of the interface as shown below . Heartbeat.JPG This particular example creates 2 separate Java windows for view and controller.After the details how this example is implemented, the author again explains the concept of MVC with respect to the example.

Graphic:File:MVC 7.JPG


Summary: This page, which is part of a tutorial, provides very basic definition of MVC and is accompanied by an instructive example of a "Spinner".
 Example:This example explains how the data in the model is displayed by the view and how an "event action" is recognized by the controller which modifies model as required. It also briefly introduces the concept of multiple controllers modifying the same model.
 Graphic:Mvc_2.JPG

This site provides a detailed overview of MVC pattern. It explains the different layers and relationship among them. It discusses the importance of structuring views, controllers and models. It contains information about the benefits and drawbacks of MVC along with the irrelevant situations where MVC will not be helpful.


Articles in Tech Republic that explain in a lucid way the MVC pattern, where it is best used and couple of its disadvantages.
This site has a detailed description of the MVC and its abstract working explained in detail. Though it is actually a chapter from textbook referring rarely to previous chapters , it gives a very detailed( in fact most detailed description of MVC with simple examples along with advantages of each feature of the MVC design pattern.

Example Description: Clock

The site is important for understanding the basics of MVC architecture. It provides an explanation about the advantages of using MVC architecture.
It defines the MVC design pattern and explains the concept and how it helps simplifies the developer’s work and also improves the maintainability of the code
This the pdf of a MVC seminar used by UC Berkeley. Though not descriptive it gives a bird eye view of MVC operates along with a simple example.
This link is the Wiki entry for MVC providing its description and various links to MVC implementations in different programming languages.

"Implementation Specific" Websites

The following sites illustrate the implementation of MVC in different programming languages like SmallTalk (MVC was originally created for this), Java, Ruby, ASP .NET etc.

This provides the paper by Steve Burbeck, who initially proposed the concept of MVC for Small Talk programming. It provides overview of how to use to MVC for application programming in Smalltalk. It discusses the communication within and between the 3 layers of MVC. It contains information about existing view hierarchy. Some of the existing views are browsers inspectors and debuggers.
This site gives a simple example of Temperature Control system implemented in java using the Observer and Observable ( these classes have been defined in java in order to implement the MVC architecture in Java) .This site explains in a very instructional way of how to implement MVC in java.
This site highlights the importance of MVC patterns and its application in many GUI-based applications, client interfaces, and widget toolkits for manipulating and storing data for the end users. Java’s Swing toolkit is a perfect example. The site explains the implementation of MVC in swing. It provides a listing of all components in the model interface. There is a sample code that would help a user to see the functionality of all examples.
This poses a simple situation where the MVC design pattern can be applied and used to solve the problem using JSP’s to render the views, Servlets as controllers, EJB as models
This is a very detailed instructional tutorial aimed at developing a MVC CRUD (Create, Read, Update, Delete) application in Ruby on Rails
This is a blog entry on MVC through the viewpoint of a Ruby on Rails developer defining MVC and giving minor details as to how MVC is implemented in Ruby on Rails.
This is an article on the Ruby on Rails official website defining the MVC usage in Rails along with links to articles within the same website for better understanding of MVC.
This is a free download of pdf format of a book “Build your own Ruby on rails applications” by Patrick Lenz. This free pdf download expires by initial days of December//'2007//. This book provides a very wonderful development from the basics of Ruby to Ruby on Rails(RoR) and the MVC architecture explained and shown how it is embedded in RoR. This comes in conjunction with easy to learn illustrations
The site provides a detailed but a simple overview of Model View Architecture with ASP.Net. It has pictorial representation of the MVC Framework. The picture will help the user to see the implementation of MVC and helps provide understanding of interactions present in MVC. Moreover there is an example of simple web site development to authenticate the user’s name and password by comparing the data with the database.
The website explains the application of MVC’s 3 Tier architecture for web development using PHP. It gives a comprehensive view of how to blend MVC architecture with Object oriented capabilities of PHP. It highlights the importance of reusability of code which is one of the most important advantages of MVC architecture.
This site will help a new user to realize the importance of Model View Architecture. It mentions the problems faced by programmer who do not implement this 3 tier architecture and how the problems are resolved using MVC architecture. There is a section where they discussed about the testability which is greatly enhanced by employing this architecture. It also contains information about its benefits and liabilities.
This site is an extension to earlier site and provides detailed explanation about the usage of MVC architecture in Java’s Swing. This site is for the advanced users who need to apply MVC in visual programming.
This provides pictorial representation of applications of MVC in Java. It contains images along with explanation for the MVC pattern used in Java explaining MVC and how is it integrated with JSP and struts in Java.
This site discusses MVC usage in web based development particularly in .NET and AJAX framework.

The sites mentioned above are very useful for several programmers such Java, PHP, Smalltalk programmers. It provides a background for new users who would like to implement design patterns hand in hand with software engineering techniques. Most of the sites explain the MVC as a part of implementation of MVC in their specific software or application. Only a few sites actually deal with the concept illustrating it in a lucid way with simple instructional examples.