MVC Paper
MVC Paper
net/publication/324828895
CITATIONS READS
0 316
2 authors, including:
Octavian Dospinescu
Facultatea de Economie si Administrarea Afacerilor
45 PUBLICATIONS 79 CITATIONS
SEE PROFILE
Some of the authors of this publication are also working on these related projects:
All content following this page was uploaded by Octavian Dospinescu on 29 April 2018.
Abstract
In this article we analyzed the Model-View-Controller paradigm (MVC) in detail through two
modern technologies (.NET and Java). Starting from MVC's evolution and concepts, we analyzed the
defining components of the model and conducted a comparative case study that looked at the
following aspects: security degree, total cost, application complexity, runtime, portability, user
interface. The results are presented in detail for each platform. After performing the comparative
analysis, we identified several future directions for the Model View Controller pattern.
Technology is constantly evolving, and to be in the top is vital to keep up with the changes. Any
company that wants to be efficient must take advantage of new IT solutions to optimize their internal
processes. The complexity of applications is rendered by the interface, which changes at an alert
pace, with consistent differences compared to previous versions. The graphical interface is intuitive
and easy to use even for a simple user, but this is hard to test, and an application typically has more
interfaces. Because the user interface changes very often, emphasis has been placed on separating it
from the logical component behind and determining the behavior of the application.
Over time, there have been many solutions to this problem, but one of the most used and known in
web application development is the Model-View-Controller pattern. It was invented by Trygve
Reenskaug when he was working at the Xerox Palo Alto Research Center. His first work (Reenskaug
1979)was written in 1978, the original model being called Thing Model View Editor. The pattern was
first implemented as a SmallTalk-80 programming language library (Krasner and Pope 1988) and
was used to create Graphical User Interface (GUI).
The initial significance of the Model View Controller was very different from the meaning of the
model today. Below are the two models and the differences between them. In the context of a
graphical user interface (first version), Model View Controller was interpreted as follows (Walther
2008):
- the Model component: represents the data of an object/object structure in an application;
- the View component: a view of the model data, the same model being represented by
multiple views. For example, a grade can be written in numerical or lettering;
- the Controller component: collects the user input data and modifies the model. For
example, when double clicking on a web interface, it changes and displays something else (model
data has changed).
4728
Innovation Management and Education Excellence through Vision 2020
It can be seen from the above figure that the View element is updated through the Model component
and not the Controller (between the Controller and the View component is not a link). Instead, the
Controller modifies the Model component and, as the View element observes the pattern,
pattern, the view is
updated. When the pattern changes, an event is triggered, and the changes in Visualization occur in
response to the event.
In the current version of Model View Controller, there is no longer any relationship between the
View and Model component. All communication between visual and persistence is achieved through
the Controller.
4729
Innovation Management and Education Excellence through Vision 2020
A software solution developed with the MVC architecture has the following mode of operation:
1. The user interacts with the interface (example: click on a radio button);
2. The controller receives this event, validates it and transmits it to the Model element;
3. The Controller also tells the Model that the state must change due to user interaction on the
interface (example: That radio-button could indicate the person's type, and after ticking an option (M
or F) the BD field is updated);
4. A View interrogates the Model in relation to the current state and the Controller sends it to the
View New State. (Example: View updated with old status plus gender confirmation)
5. The interface stays "static" until the next user action.
The Model component is the primary element of this architecture and explains the behavior of the
application, independent of the user interface. The model encapsulates data and procedures that help
in the specific processing of the application. Controllers call these procedures on behalf of the user,
and the View component displays the new changes that occur in the interface. The model also
provides functions that can access the data that is displayed. The change-propagation mechanism
maintains a dependency register within the model, which changes the element in the interface, the
View and Controller components are announced. The model is usually both a database and business
logic behind the application.
A view can be any form of representation of an output, such as graphs, tables or diagrams, and so on.
Each view is an update procedure that is enabled by the change-propagation mechanism. When a
procedure is called, the View component receives the current Model data and displays it on the
screen. The View is the interface of the software solution and transmits to the Controller all the
actions that take place.
The View component often offers the functionality that allows Controllers to manipulate the display.
This is useful for user-initiated operations that do not affect the Model (does not change Model data),
such as the scroll (no changes to the database).
A web application is usually composed of a set of controls, patterns, and views. The first component
can be structured in the form of a main Controller that receives all requests and calls the Controller
dealing with a particular case. Its role is to coordinate data between the two classes of objects
(Ibrahim 2006), (Sarker and Apu 2014).
The controller connects between Model and View, between user actions and the logical part of the
application. Depending on the user's needs, the Controller calls various functions specifically defined
for the site section in which they are located. This component contains the most code lines as it is the
means by which the user interacts with the application. Due to the fact that Model View Controller is
4730
Innovation Management and Education Excellence through Vision 2020
an organizational pattern, not a concrete implementation technique, most modern platforms (.Net,
Java, Python, etc.) allow the use of this model by incorporating web frames that help the developer
structure application. Complex web solutions can have many code lines, so it's a good idea to
structure your application architecture right from the start. There are many techniques available to
create a web application, but all of these techniques have some advantages and disadvantages. In this
article, we'll focus on Active Server Pages (ASP) and Java Server Pages (JSP), which are two of the
most important techniques for implementing the MVC pattern. The Model View Controller pattern is
further shown for each platform specified above.
Figure 4 shows how the main components of a web solution (developed using the MVC .Net ASP
framework) interact.
1. The user attempts to access the web page / resource through a URL (Uniform Resource Locator);
2. The HTTP request reaches the first component of the MVC architecture, this being the routing
engine (the routing engine);
3. Based on mapping between URLs and Controllers, the routing engine searches for the
corresponding URL controller. If the controller is found, it is invoked;
4. The controller interacts with the model based on the user's HTTP request. If data is received from
the user, the model is updated and the controller receives the new "status" of the application; 5. The
controller sends to the View component the current status of the application;
6. The controller sends the result received from View to the browser as part of the HTTP response;
7. The browser receives the HTML generated by the application.
ASP.NET framework assures the independence of the Model, View and Controller components
(separates business logic from UI logic), while providing a weak link between these elements and can
communicate.
4731
Innovation Management and Education Excellence through Vision 2020
- The model: encapsulates the application data and will generally be composed of POJO (Plain Old
Java Objects) classes. By using POJO classes, the code can be simplified, and this leads to better
application testing, flexibility, and so forth (Stark 2015).
- View: is responsible for rendering data in the HTML format so that the browser can interpret the
output (Kruk, et al. 2017);
- Controller: is the intermediate between the two elements specified above.
The following is how the elements of a web solution developed in Spring communicate.
1. After receiving an HTTP request, DispatcherServlet (also called the Front Controller in some
versions of the MVC Spring Frame) communicates with Handler Mapping to establish the Request
Controller;
2. The controller picks up the request and calls the methods according to the type of request:
GET/POST etc. In turn, these methods will update the Model data and transmit the View Name to the
Dispatcher;
3. DispatcherServlet will communicate with ViewResolver (maps a real view of each view name) to
get the View View;
4. In the last step, the model is rendered and the output (HTML) required for the browser is
generated.
Finally, we will realize that using a pattern design, such as Model View Controller, will help us
develop a web application much faster. Using this pattern, web solutions will be easy to upgrade
(scalable), easy to test and easier to maintain.
4732
Innovation Management and Education Excellence through Vision 2020
For a better understanding of these implementations, we will create a class called "Student" and it
will have two attributes: "name" and "last name". The user can set and get the value of these
properties through the setters / getters, and besides, he can check using the isValid method if the
name / surname is valid
J2EE (Java 2 Platform, Enterprise Edition) vs. ASP .Net (Active Server Pages .Net)
- Model: In J2EE the model is represented by Java bean classes, and in ASP .Net simple classes with
setters and getters. Below is the code for both cases.
Figure 6 : The class “Student” iin Java Figure 7 : The class “Student” in
i .Net
The next main element to be explained is the view. It is built with tags (</>) and represents the most
visible component of the application, that is, the interface.
Controller: To create a controller in J2EE, we need a class that inherits the "HttpServlet" class. The
controller logic is implemented by a method that takes two instances of the Servlet HTTP class as
parameters: a Servlet Request HTTP instance and one Response (Aniche, et al. 2017).
To create a controller in ASP.Net we need a class that implements the IHttpHandler and
IRequiresSessionState interface. Below is the code for both cases.
4733
Innovation Management and Education Excellence through Vision 2020
Table 1 lists the main differences between applications developed using the MVC ASP.Net
framework and those developed with the Spring MVC framework.
frame
Table 1: Applications developed in ASP.Net MVC vs. Applications developed in Spring MVC
4734
Innovation Management and Education Excellence through Vision 2020
.NET and Java have long been on the market and are both modern development platforms. However,
when we have to make a decision about the platform we want to use, there are some main aspects can
be considered (RishabhSoftware 2017):
1. Complexity of the applications - the general perception is that .Net is easy over Java in terms of
solutions that need a richer graphical user interface. On the other hand, Java is over .Net for
applications that support a large amount of data or users.
2. Portability - As we have seen in the table above, Java has multi-platform compatibility and gives
us the freedom to choose the provider. Organizations choose Java when integrating the application
with the operating system is a priority.
3. Employee Software Development Skills - It is very important to take into account the
infrastructure and capabilities of today's developers because replacing and developing an
infrastructure can greatly increase costs.
MVC is widely used and many web applications are based on the pattern Model View Controller
Model View Controller can be found in two forms:
The View View Controller on the front end is usually built with a frame, developed in most cases in
JavaScript (for example, Angular Js). The Controller component also has a large part of the
application's behavior, but it is saved on the station (client) (Harms, Rogowski and Lo Iacono 2017).
The main difference between server-side MVC and client-side MVC is given by the way web pages
are rendered. In the first case, HTML is always fully loaded when we use the application, contrary to
the MVC on the front end where the HTML code is loaded and modified only in the parts where the
user acted.
In 2017, client-side applications were dominant, especially single-page software solutions - these
solutions load once the initial page and then request multiple pieces of data through Ajax calls. The
problem with these applications is that as users rotate around the page, they create a lot of Ajax
requests on the server, which slows the application (Moldovan 2016).
Model View Controller is now the best way to develop server-side applications, but this architectural
pattern can not be used on the client side because it does not respect its principles and component
independence (the View component is tightly linked by the Controller in this case).
Another problem encountered in the developed applications based on the client-side MVC pattern is
related to the data stored in the Model component. On the one hand, we have data such as users and
products, which are the status of the application, and on the other hand, we also need to store the
status of the interface through elements such as showTab or selectedValue. Similar to the problem
encountered in the Controller, the Model component violates the principle of unique responsibility
because there is no separate way to manage the status of the application and the state of the interface.
Recently, a number of new frameworks have been introduced that promote the unidirectional data
flow concept and solve the problems encountered in the client-side MVC pattern. In short, the new
architecture attempts to make predictable changes to the status of the application by imposing certain
restrictions on how and when updates can take place. The most notable architecture is Flux and the
4735
Innovation Management and Education Excellence through Vision 2020
most notable framework is React (Simkhada 2017). For now, there are few software developers who
have adopted this method, but as they begin to uncover the benefits of unidirectional architectures,
many will head to that direction. Flux is the application architecture that Facebook uses to build web
client software solutions. It solves the problems encountered in the Model View Controller pattern
and respects the principle of unique responsibility using a one-way data stream (Flux in depth
overview 2015).
Given the above-mentioned arguments, it is expected that in the near future we will no longer use the
MVC classic architecture to develop front end applications, but only back end applications (based on
the server). Front end (client) software solutions will be developed with the new Flux architectural
pattern. Every day, more and more software developers begin to see the benefits of unidirectional
components and architectures, with the emphasis on building tools and better libraries in the future.
References
Ahmed, Mustafa. 2016. "Implementation of Course Scoring System Based on Spring MVC and
Hibernate." Culminating Projects in Computer Science and Information Technology 13.
http://repository.stcloudstate.edu/csit_etds/13.
Aniche, Maurício, Gabriele Bavota, Christoph Treude, Marco Aurélio Gerosa, and Arie van Deursen.
2017. "Code smells for Model-View-Controller architectures." Empirical Software Engineering 1-37.
doi:https://doi.org/10.1007/s10664-017-9540-2.
Aygun, Coskun, and Emre Kazan. 2015. "The Performance Analysis of Applications Written Using
MVP and MVC." INTERNATIONAL JOURNAL OF SCIENTIFIC RESEARCH IN INFORMATION
SYSTEMS AND ENGINEERING 1 (2). http://ijsrise.com/index.php/IJSRISE/article/view/33.
2015. Flux in depth overview. Facebook Inc. Accessed 2018. https://facebook.github.io/flux/docs/in-
depth-overview.html#content.
Freeman, A. 2014. Pro ASP.NET MVC 5 Platform. Apress, Berkeley, CA.
doi:https://doi.org/10.1007/978-1-4302-6542-9_1.
Freeman, A. 2017. "Understanding Angular and ASP.NET Core MVC." In Essential Angular for
ASP.NET Core MVC. Apress, Berkeley, CA. doi:https://doi.org/10.1007/978-1-4842-2916-3_1.
Harms, Holger, Collin Rogowski, and Luigi Lo Iacono. 2017. "Guidelines for adopting frontend
architectures and patterns in microservices-based systems." Proceedings of the 2017 11th Joint
Meeting on Foundations of Software Engineering. 902-907. doi:10.1145/3106237.3117775.
Ibrahim, N. 2006. "Applying a Model/View/Controller Pattern in J2EE Platform Using Struts
Framework." Jurnal Sistem Informasi 1 (2): 129-147.
http://jutisi.maranatha.edu/index.php/jusi/article/viewFile/205/203.
Krasner, Glenn, and Stephen Pope. 1988. "A Description of the Model-View-Controller User."
Journal of object oriented programming (ParcPlace Systems).
https://www.researchgate.net/profile/Stephen_Pope/publication/248825145_A_cookbook_for_using_
the_model_-_view_controller_user_interface_paradigm_in_Smalltalk_-
_80/links/5436c5f30cf2643ab9888926/A-cookbook-for-using-the-model-view-controller-user-
interface.
Kruk, G., O. Alves, L. Molinari, and E. Roux. 2017. "BEST PRACTICES FOR EFFICIENT
DEVELOPMENT OF JAVAFX." 16th Int. Conf. on Accelerator and Large Experimental Control
Systems. Barcelona, Spain: JACoW Publishing. 1078-1083. Accessed 2018.
doi:doi:10.18429/JACoW-ICALEPCS2017-THAPL02.
4736
Innovation Management and Education Excellence through Vision 2020
4737
Proceedings of
st
the 31 International Business Information Management Association Conference
(IBIMA)
ISBN: 978-0-9998551-0-2
Editor
Khalid S. Soliman
Copyright 2018