Thursday, September 22, 2011

MVC Pattern Basics

Definition
The Model-View-Controller (MVC) architectural pattern is used in software engineering to allow for the separation of three common features in GUI applications:
  • the data access (typically via a database)
  • the business logic (how the data will be used)
  • user interaction (how the data and actions will be visually presented)

MVC pattern differenciates all the 3 aspects of application in 3 difft tiers.

Modal
It incorporates following point
  •  Holds the business logic of the application.
  •  holds data sent between different. tiers like JSP to servlet and handler classes.
  • One of the goals of the model is to give a presentation which does not directly refer to any specific DBMS. 

View
  • This represents the visible user interface, so handles presentation tier of the application.
  • it knows enough about the data to create a coherent presentation, but does not actually do the work of presenting the data. Instead, it provides the ability to manipulate data outside the View through event handlers defined within. 
  • handles presentation logic, client side validation.
  • e.g. HTML, JSP

Controller
  • handles the flow of the application
  • Joins the Model with the View and is the heart of the business logic.
  • It is the source of activity when an event occurs and defines the event handling actions which access data (from the Model) and are presented to the user (in the View).
  • e.g. Servlets, Action Class in Struts, ActionServlet is using struts-config.xml as front controller to handle each request and redirect it to appropriate destination.

Advantages
  •  Increases modularity of the application.
  •  Increases Maintainability of the application, i.e.  the data presentation can be changed without any notion of how the data is obtained and conversely, the data access can be changed without any knowledge of how it is to be presented. 
Example
to be added soon

    No comments:

    Post a Comment

    Chitika