By,
Veena Sawant
MVC is
popular as it isolates the application logic from the user interface layer and
supports separation of concerns. Here the Controller receives all requests for
the application and then works with the Model to prepare any data needed by the
View. The View then uses the data prepared by the Controller to generate a
final presentable response. The MVC abstraction can be graphically represented
as follows.Model–view–controller (MVC) is a software architectural pattern
mostly for implementing user interfaces (but not only for user interfaces). It
divides a given software application into three interconnected parts, so as to
separate internal representations of information from the ways that information
is presented to or accepted from the user.
Traditionally
used for desktop graphical user interfaces, this architecture has become
extremely popular for designing web applications.Model View Controller or MVC
as it is popularly called, is a software design pattern for developing web
applications. A Model View Controller pattern is made up of the following three
parts:
Models :The lowest level of the pattern
which is responsible for maintaining data. Models represent knowledge. A model
could be a single object (rather uninteresting), or it could be some structure
of objects.
The model
is responsible for managing the data of the application. It responds to the
request from the view and it also responds to instructions from the controller
to update itself.
There should be a one-to-one
correspondence between the model and its parts on the one hand, and the
represented world as perceived by the owner of the model on the other hand.
Views :This is responsible for displaying
all or a portion of the data to the user. A view is a (visual) representation
of its model. It would ordinarily highlight certain attributes of the model and
suppress others. It is thus acting as a presentation filter.
A
presentation of data in a particular format, triggered by a controller's
decision to present the data. They are script based templating systems like
JSP, ASP, PHP and very easy to integrate with AJAX technology.
A view is attached to its model (or
model part) and gets the data necessary for the presentation from the model by
asking questions. It may also update the model by sending appropriate messages.
All these questions and messages have to be in the terminology of the model,
the view will therefore have to know the semantics of the attributes of the
model it represents.
Controllers :Software Code that controls the
interactions between the Model and View. A controller is the link between a
user and the system. It provides the user with input by arranging for relevant
views to present themselves in appropriate places on the screen. It provides
means for user output by presenting the user with menus or other means of
giving commands and data. The controller receives such user output, translates
it into the appropriate messages and pass these messages on to one or more of
the views.
The
controller is responsible for responding to user input and perform interactions
on the data model objects. The controller receives the input, it validates the
input and then performs the business operation that modifies the state of the
data model.