CSC/ECE 517 Fall 2012/ch1 1w20 pp: Difference between revisions
Line 19: | Line 19: | ||
==Advantages and disadvantages of MVC pattern== | ==Advantages and disadvantages of MVC pattern== | ||
==='''Advantages'''=== | ==='''Advantages of MVC pattern'''=== | ||
* You can distribute development effort to some extent, so that implementation changes in one part of the Web application do not require changes to another. The developers responsible for writing the business logic can work independently of the developers responsible for the flow of control, and Web-page designers can work independently of the developers. | |||
* You can more easily migrate legacy programs, because the view is separate from the model and the control and can be tailored to platform and user category. | |||
* Isolation of business logic from the user interface | |||
* Ease of keeping code DRY | |||
* Making it clear where different types of code belong for easier maintenance | |||
* Since MVC separates the application into the model, view and controller components, it increases the maintainability of the application | |||
* Testing is easier since the components are independent. | |||
* Multiple views can reuse the same model objects, thus facilitating code reusability. | |||
* MVC architecture helps in developing loosely coupled systems | |||
* The modularity of MVC enables easier changes to the user interface. | |||
==='''Disadvantages'''=== | ==='''Disadvantages'''=== |
Revision as of 21:57, 14 September 2012
Introduction
A common feature of today’s web applications is to retrieve data from a data store and display it for the user. The system stores the updates in the data store when the user changes the data. The flow of information between the data store and the user interface might compel the computer programmer to tie these two pieces together to reduce the amount of coding. This approach has significant problems. User interface logic tends to change more frequently than business logic, especially in Web-based applications. If user interface code and business logic are combined in a single object, you have to modify an object containing business logic every time you change the user interface. Also, in most cases, the application displays the same data in different ways. Tight coupling between the presentation and business logic would mean that the same code is repeated at multiple places. This reduces the maintainability and flexibility of the application.
The Model-View-Controller (MVC) pattern separates the modeling of the business logic, the presentation, and the actions based on user input into three separate classes:
- Model: The model manages the behavior and data of the application domain. It responds to requests for the user interface(view), and responds to instructions from the controller to change state.
- View: The view refers to the user interface and manages the display of information
- Controller: The controller interprets the inputs from the user, informing the model and/or the view to change appropriately.
History
The invention of MVC is attributed to Trygve Reenskaug, who was working at Xerox PARC at the time. The 80s decade saw the first implementations of the MVC framework in the form of smalltalks-80. MVC, which was a key feature of the language (Smalltalk) was designed for desktop applications with the main concern being the separation of the presentation from the domain model.
MVC pattern in web application development
Web frameworks using MVC pattern
Advantages and disadvantages of MVC pattern
Advantages of MVC pattern
- You can distribute development effort to some extent, so that implementation changes in one part of the Web application do not require changes to another. The developers responsible for writing the business logic can work independently of the developers responsible for the flow of control, and Web-page designers can work independently of the developers.
- You can more easily migrate legacy programs, because the view is separate from the model and the control and can be tailored to platform and user category.
- Isolation of business logic from the user interface
- Ease of keeping code DRY
- Making it clear where different types of code belong for easier maintenance
- Since MVC separates the application into the model, view and controller components, it increases the maintainability of the application
- Testing is easier since the components are independent.
- Multiple views can reuse the same model objects, thus facilitating code reusability.
- MVC architecture helps in developing loosely coupled systems
- The modularity of MVC enables easier changes to the user interface.
Disadvantages
Examples
References
<references/> 1. http://heim.ifi.uio.no/~trygver/themes/mvc/mvc-index.html
2. http://en.wikipedia.org/wiki/Web_application_framework
3. http://en.wikipedia.org/wiki/Model-view-controller
5. http://www.typo3-media.com/blog/mvc-mvp-typo3-introduction.html