Introduction to ASP .Net MVC
MVC (Model View
Controller) is a software architecture pattern that is used for separation of
concern where application development in ASP .NET, JAVA, PHP, etc are using it
to keep cleaner codes. One area of UI concern should not depend on business logic
or data access and vice versa.
From above statement,
you come up with several questions about "what is separation of
concern?", "What is cleaner codes?" and several other whats.
I break down those into
details with ASP .NET and you will know what MVC is and how it works by the end
of this article.
What is Separation of
Concern?
Before MVC, ASP .NET Web
Form uses events driven approach programming. For example, when you drag and drop
a text box and double click on it, it has built-in event codes. Using two or a
few items like textbox or dropdownlist is ignorable. It seems easy to work, but
it comes with so much disadvantages. But when you are developing large-scale
application, it becomes complex to understand how all the codes work behind the
scene. If any changes need to make, it becomes hectic work to complete and
there is no traceability of codes.
For those reasons, MVC
comes into picture. In a typical application of MVC, we can break down into
three layers for application development as you may already expect: Model, View and Controller
Model represents how
data is structured, stored and access to database. This layer is interchangeably
called Data Access Layer or Business Logic Layer.
View represents what
user see on the screen or View takes inputs from users to request what they
want to see. The View layer is also called Display Layer. In View, you do not
have option to click on toolboxes where Web Form usually takes you into code-behind
cs file. This gives developers full control over how UI should be designed and
layout. View can be created strongly-type from Model Layer, which expert
developers recommend to do.
Controller represents as
input control manager who respond and redirect View's requests (user inputs) to
the appropriate Model. This layer take in what user are requesting and will
either pass to Model Layer to retrieve data or calculate and process the logic
inside controller and pass back to View to display the result.
Here is MVC flow diagram.
MVC also helps to
separate frontend and backend developers. While frontend developers are working
on UI, backend developers can work on the business logic and data access logic
at the same time.
Later section, I will
discuss about how MVC is used with demo.

No comments:
Post a Comment