Hello Folks,
In the world of web application development, we can develop web applications using various technologies. ASP.NET is one among many.
Again in ASP.NET, we have two ways to develop web applications, WEB Forms and MVC. These two methods are there on top of Microsoft .NET Framework and have all of its features.
»ASP.NET Web Forms Quick Review
In the world of web application development, we can develop web applications using various technologies. ASP.NET is one among many.
Again in ASP.NET, we have two ways to develop web applications, WEB Forms and MVC. These two methods are there on top of Microsoft .NET Framework and have all of its features.
Fig 1: Web Application Development |
Recently,
a lot of discussions are going on whether Microsoft's relatively
new Model View Controller (MVC) technology will replace .NET
Web Forms as the superior web application development technology. Before deciding which one is better, lets have a glance at following points.
»ASP.NET Web Forms Quick Review
- ASP.NET Web Forms for Web Development
- ASP.NET Web Forms-Development characteristics
- ASP.NET Web Forms-Major disadvantages
»Introduction
to MVC
- Design Pattern
- MVC Control Flow
- Driving Goals of MVC
- Benefits of MVC
ASP.NET Web Forms Quick Review |
- ASP.NET Web Forms for Web Development
»ASP.NET Web Forms
- A Visual Studio .NET application type for building web applications
- One of the three different programming models you can use to create ASP.NET web applications
- Has been in the market ever since Visual Studio .NET 2002
- A step further from ASP web applications technology, using the .NET Framework
- Latest version is ASP.NET 4.5 that uses .NET Framework 4.5
»Easy-to-use Web Development & Deployment- You can use HTML pages, JavaScript, CSS, etc. along with ASP.NET web forms for providing better user experience.
- Supports configurability through Web.Config file.
- ASP.NET
Web Forms-Development characteristics
»The ASPX screens
- Mark-up is like HTML
- Use ASP.NET server controls primarily
- Has a code-behind file(.cs file)
»The ASPX code-behind file- This is where you do the server-side logic
- Handles:
- ASP.NET
Web Forms-Major disadvantages
- View states can be large
- “PostBack” approach for server-side processing
- A big presentation layer code in C# is NOT unit-testable
- Presentation layer code that does everything
Introduction
to MVC |
A better,
more maintainable
Development Approach is required for the Presentation Layer, leads to MVC.
- Design
pattern:
A design pattern describes a proven solution to a recurring design problem, placing particular importance on the context and forces surrounding problem, consequences and the impact of the solution.
MVC is one of the design patterns. MVC stands for Model-View-Controller.
»“M” – Models: Tthe source of Application Logic, and Data- Contains application business logic (“model services”) and data (“models”)
- “Models” represent entities of business domains, which can be “bound” to a suitable “View”
»“V” – Views: For presenting and accepting user-made changes to data
- Helps to present data in “Models”
- You can have multiple “Views” corresponding to the same “Model” instance
»“C” – Controllers: Responsible for handling user inputs (incoming HTTP requests)- Handles user action
- In the case of a web app, Controller decides which view to show for incoming HTTP requests from browsers.
- MVC
control flow
Though MVC comes in different flavors, the control flow generally works as follows:
- The user interacts with the user interface in some way (e.g., user presses a button)
- A controller handles the input event from the user interface, often via a registered handler or callback
- The controller accesses the model, possibly updating it in a way appropriate to the user’s Action. Complex controllers are often structured using the command pattern to encapsulate actions and simplify extension
- A view uses the model to generate an appropriate user interface. The view gets its own data from the model. The model has no direct knowledge of the view (However, the observer pattern can be used to allow the model to indirectly notify interested parties, potentially including views, of a change)
- The user interface waits for further user interactions, which begins the new cycle
Fig 2:MVC Control Flow summarizes the relationship between the Model, View, and Controller is provided below.
Fig 2:MVC Control Flow
- Driving
goals of MVC
- Clean separation of concerns
- Highly extensible and pluggable architecture
- Powerful URL routing component
- Includes existing .NET features Master pages(only in MVC2, later versions have layout), content pages, etc.
- Full control of HTML markup
- Since MVC3 Razor view engine has been introduced.
- Benefits
of MVC
- Testability
- Flexibility
- Extensibility
- Perfect for team work
- Powerful Routing System
- Ready-made ASP.NET platform features
- ASP.NET MVC meshes so well with the popular jQuery library
- MVC Framework crafts a simple, elegant markup styled with CSS
Conclusion
|
Web Forms vs. MVC, which one is better?
There
is no straightforward answer, and rightly so; they both provide different means
to reach the same end. Even Scott Guthrie of the MVC development team stated
that, "Different customers look for different programming approaches, and
a lot love Web Forms and think it is great. Others love MVC and think it is
great. That is why we are investing in both".
In terms of development speed, which would be faster: webforms or mvc?
This depends on many factors, but suppose that you use equal
technologies both with Webforms and MVC then MVC should be faster.
Web forms has some overhead because of the mismatch between how things
really work (eg. that http is stateless) and what is assumed while
writing the code (you're programming as if the application was stateful).
On long term basis, which would be easier to maintain?
In my opinion, MVC is easier to maintain, because it's easier to change bare
html/js code, the model(MVC) is well defined which makes it, less painful
for a new person to figure out how everything works.
Hope this helps, Happy Coding.!!
Please do like, If you find this post insightful.
Thanks,
Ram
No comments:
Post a Comment