subcontrollers first, so that input is processed at the
lowest levels of the controller hierarchy first.
User input and output devices form an implicit
fourth component of the MVC pattern. The
Smalltalk system was based on a graphical display
and standard user input devices, primarily a
keyboard and mouse. User menus were also
considered to be a type of virtual device that
transmitted input to the controller hierarchy just as
the keyboard or mouse did. Though menus were
implemented in the GUI, they were not considered
as view components.
The primary benefit of the MVC design pattern
is separation of concerns and the resulting
modularity. The design isolates user interface
presentation from user input handling, and isolates
both of these from application state and transaction
processing. This makes it possible to modify or
replace one component without needing to modify or
even understand the others. It also facilitates
extensibility by making it possible to add a
view/controller pair for a new interface medium, or
to add new functionality to the model independently
of the other components.
3 MVC IN WEB FRAMEWORKS
ASP .Net MVC 2 is the latest version of the
Microsoft web development framework (Esposito,
2010). It adds the MVC design architecture to earlier
versions of ASP .Net based on Web Forms. The
ASP .Net MVC 2 framework uses a single handler
for HTTP requests that determines and instantiates
an appropriate controller for each request.
Controllers are responsible for handling incoming
requests, orchestrating transaction processing by the
model, preparing data for the subsequent view
element, and activating that view element to
generate the response. A controller class can include
multiple actions that respond to different types of
requests, each action being a unique public method
of the class. Views are defined in ASP files, which
are HTML templates with server-side scripts that
can generate dynamic content. Each view receives
information from the controller that activated it,
either as native objects or as view-model objects,
which are unique compilations of data from the
model, each designed for a specific view. The model
component is intended to contain application logic
and database access. A differentiation is made
between view models, which are data structures
intended to convey information to a specific view
element, and application models, which are domain
entities and related transactions that operate on
them. The model component also provides object-
relational mapping, which hides the details of how
application domain objects are mapped to database
tables.
Rails is a web application framework developed
for use with the Ruby programming languages
(Thomas and Hansson, 2007). HTTP requests are
handled in Rails through a central router that directs
requests to the appropriate ActionController class
and method within the controller component.
ActionController objects are responsible for filtering
request parameters, for orchestrating transactions by
invoking methods of appropriate model elements,
and for arranging the appropriate view response.
ActionControllers also arrange for view elements to
have access to data from the model. The controller
elements are also responsible for web session
management, including cookie management. The
user interface (view component) is presented
through dynamic document templates that are
standard HTML documents with embedded Ruby
scripts, similar to ASP, PHP, JSP, etc. View
elements can access the model component as
necessary to obtain data for presentation. The Rails
model component includes elements that encapsulate
application logic and transaction processing
(ActiveModel), and an object relational mapping
scheme (ActiveRecord) that associates each database
table with a model element. The model also includes
ActiveResource elements that provide access to
external resources.
The Apache Struts 2 framework is based on Java
2 Enterprise Edition (J2EE) and Java Server Pages
(JSP) technology. Struts2 view components are JSP
documents with embedded tags that provide a
variety of functionality, including flow of control
(iteration, conditionals), access to Java Beans
(model components), and streamlined HTML Forms
construction. Controller components of a Struts2
web application are embodied in actions, which are
Java classes. An action can respond to user input
from one or more JSPs. The primary responsibilities
of each action are to validate user input and to
orchestrate transaction processing by invoking
appropriate model operations. Actions are defined
and configured through an XML configuration file
or through the Java annotation mechanism. This
configuration information also controls the flow of a
web application by determining what view follows
each action, depending upon the outcome of the
action. A central part of Struts2 is the Value Stack,
where information flowing between view and
controller is stored and converted as needed. This
WEBIST 2011 - 7th International Conference on Web Information Systems and Technologies
128