More Related Content
Similar to Aspnet mvc vs_web_forms_final
Similar to Aspnet mvc vs_web_forms_final (20)
Aspnet mvc vs_web_forms_final
- 1. THE POWER OF PERSPECTIVE
ASP.NET MVC vs. Web Forms
.NET Track
Thiago Silva
Credera
Copyright © 2011 Credera. All Rights Reserved.
- 2. www.credera.com
About the Speaker
Thiago Silva is a software and business intelligence consultant, based out of Dallas
Texas. He is an architect for the Microsoft practice at Credera in Dallas and has helped
several clients implement custom software, SharePoint, business intelligence, and
reporting solutions using .NET and SQL Server technologies.
Thiago is co-author of the book "Professional SQL Server 2008 Reporting Services" by
Wrox Publishing, and contributor on the book "Microsoft SQL Server Reporting
Services Recipes: for Designing Expert Reports".
You can visit his blog, Silvaware, at http://silvaware.net, and follow him on twitter at
http://twitter.com/tafs7
Copyright © 2011 Credera.
-2-
All Rights Reserved.
T H E P O W E R O F P E R S P E C T I V E
- 3. www.credera.com
Agenda
MVC
– The Good Stuff
– The Bad Not So Good Stuff
Web Forms is dead! Long live Web Forms!
– The Good Stuff
– The Bad Not So Good Stuff
ASP.NET – The Platform…THEY MEET IN THE MIDDLE!
MVC Takes On Web Forms
– High Level feature comparison
– Detailed feature comparison
MVC Learning Curve
Show me the code!
Copyright © 2011 Credera.
-3-
All Rights Reserved.
T H E P O W E R O F P E R S P E C T I V E
- 4. www.credera.com
MVC 101
Software Architectural Pattern (NOT A FRAMEWORK)
First described, using Smalltalk, in 1979 by Trygve Reenskaug,
Xerox PARC
Isolates domain logic from UI/Presentation
Popular in Java and Ruby Web Frameworks
Controller
View Model
Copyright © 2011 Credera.
-4-
All Rights Reserved.
T H E P O W E R O F P E R S P E C T I V E
- 5. www.credera.com
MVC – The Good Stuff
Mature and Widely Adopted – tried and true
Fosters adoption of best practices and patterns
– Separation of Concerns
– Unit Testing/TDD and Mocking
– Loosely coupled tiers
– Highly maintainable code
Better code organization
Copyright © 2011 Credera.
-5-
All Rights Reserved.
T H E P O W E R O F P E R S P E C T I V E
- 6. www.credera.com
MVC – The Bad Not So Good Stuff
Requires deeper experience in architectural patterns and well-rounded web
development topics:
– TDD/unit testing
– S.O.L.I.D.
– HTML/CSS/JavaScript
Does not closely resemble Windows Forms development so the learning curve
is steeper for non-web developers
Might be overkill if…
– speed of development is essential
– application is simple and small
Copyright © 2011 Credera.
-6-
All Rights Reserved.
T H E P O W E R O F P E R S P E C T I V E
- 7. www.credera.com
Web Forms Is Dead! Long Live Web Forms!
OH: “now that Microsoft has ASP.NET MVC, they are going to stop supporting Web
Forms”….FALSE!
Web Forms is very much alive and with a new release, in .NET4. Here are some new
features:
– Extensible Output Caching
– Out of Proc Session State Compression
– Extensible Request Validation
– Extensible Object Caching
– Better control over ViewState
– URL Routing Support (vanity URLs = SEO!)
– Better control over generated server control IDs in HTML (for easier JavaScript
access)
– Improved HTML rendering of controls for support of web standards and accessibility
Copyright © 2011 Credera.
-7-
All Rights Reserved.
T H E P O W E R O F P E R S P E C T I V E
- 8. www.credera.com
Web Forms - The Good Stuff
Rapid Development (RAD)
– Drag and drop controls provide an abstraction layer over CSS, JS, and HTML.
– Speeds up time from prototype to final product
Simulates Statefulness
– Viewstate, postbacks, control events, and page lifecycle, all aim to simulate a
stateful model on top of an inherently stateless HTTP protocol.
– Allows developers without deep HTML and JS knowledge to write effective
applications.
Maturity
– Web Forms is stable, mature, and is fully supported by third party controls and tools
(e.g. Ajax control toolkit, Telerik, Infragistics, DevExpress, etc.)
Copyright © 2011 Credera.
-8-
All Rights Reserved.
T H E P O W E R O F P E R S P E C T I V E
- 9. www.credera.com
Web Forms - The Bad Not So Good Stuff
Abstraction from HTML
– Hinders integration with Javascript frameworks (e.g. jQuery).
– Postback model and ViewState can make it hard for search engines to rank Web
Forms pages higher due to payload size.
Difficult to adopt practices such as Separation of Concerns
– History has shown that the Web Forms model does not lend itself naturally to SOC.
– Because framework does not lend itself well to SOC, developers must make a bigger
effort to stick to best practices and patterns.
Difficult To Unit Test
– A monolithic runtime environment exposed as sealed classes is hard/impossible to
test (mock).
Copyright © 2011 Credera.
-9-
All Rights Reserved.
T H E P O W E R O F P E R S P E C T I V E
- 10. www.credera.com
ASP.NET – The Platform…THEY MEET IN THE MIDDLE!
Since both MVC and Web Forms share the same underlying platform, they can take
advantage of the same goodness that’s available in ASP.NET:
HTTP Request Roles Health Monitoring
HTTP Response Master Pages Process Model
URL Routing Microsoft ASP.NET AJAX Tracing
Session State jQuery
Caching Localization
Profiles Configuration
Security Compilation
Membership Deployment
Copyright © 2011 Credera.
- 10 -
All Rights Reserved.
T H E P O W E R O F P E R S P E C T I V E
- 11. www.credera.com
MVC Takes On Web Forms – a Feature Comparison
Feature Web Forms MVC
Server Controls *
ViewState
Unit Testing
Full HTML Control
Page Lifecycle
Separation of Concerns
Support for JavaScript
Rapid Application Development
Windows Forms paradigm
* MVC Server controls are implemented as lightweight HTML helper extension methods, and render
simple HTML and JavaScript. They do not actually maintain state or contain any server side
event/lifecycle.
Copyright © 2011 Credera.
- 11 -
All Rights Reserved.
T H E P O W E R O F P E R S P E C T I V E
- 12. www.credera.com
MVC Takes On Web Forms – Detailed Comparison
Feature MVC Web Forms
SEO Out of box MVC URLs are Web Forms can be made to work
SEO friendly with friendly URLs by manual
processes involving URL rewrites
and server transfers
Development Requires more design Code-behind is more familiar,
and separation of and often more easily utilized as
concerns, which can be the code can directly control
cause for more up from page output (e.g. calling a
effort, but better long property on a server control)
term maintenance
Separation of Concerns Inherent in the Can be achieved by diligence and
architecture process
Copyright © 2011 Credera.
- 12 -
All Rights Reserved.
T H E P O W E R O F P E R S P E C T I V E
- 13. www.credera.com
MVC Takes On WebForms – Detailed Comparison
Feature MVC WebForms
Unit Testing Easy to test the model More difficult because code-
and controller, as they behind is not required to be-
are de-coupled by the decoupled from the form
nature of the architecture
Open Source Libraries NuGet facilitates easy use Integrating open source, third
of open source, third party libraries is a more manual
party libraries, and process
JavaScript libraries are
more easily utilized
HTML / Page Weight More control over the More difficult to control HTML
HTML, easier to build because controls and server
lightweight, HTML rendering may be out of
compliant pages developer’s control
Copyright © 2011 Credera.
- 13 -
All Rights Reserved.
T H E P O W E R O F P E R S P E C T I V E
- 14. www.credera.com
MVC Learning Curve
Putting data on a page
– Need to stop thinking in terms of telling controls what to do.
– In MVC, you think in terms of providing a model that contains all the data a page
needs (a “View Model”).
– A given view specifies/defines what model data it needs to display and in what way.
Postbacks
– No support for “classic” postbacks.
– You must post to a controller action in MVC.
– MVC does not consider any URL as the endpoint to a physical server resource.
ViewState
– This concept does not exist in MVC.
– You are responsible for populating and repopulating form data.
– Model binder and view models provide help with this.
Copyright © 2011 Credera.
- 14 -
All Rights Reserved.
T H E P O W E R O F P E R S P E C T I V E
- 15. www.credera.com
MVC Learning Curve – more stuff
WebForms Page Lifecycle MVC Page Lifecycle
Copyright © 2011 Credera.
- 15 -
All Rights Reserved.
T H E P O W E R O F P E R S P E C T I V E
- 16. www.credera.com
MVC Learning Curve – even more stuff
Platform Paradigm Parallels…(say that 5 times in a row!)
WebForms MVC
Controls ≈ Html Helpers
Code Behind ≈ Controller
Events ≈ Routes and Methods
User Controls ≈ Partial Views
Master Pages = Master Pages and Shared
Views
Copyright © 2011 Credera.
- 16 -
All Rights Reserved.
T H E P O W E R O F P E R S P E C T I V E
- 17. www.credera.com
Demo
Copyright © 2011 Credera.
- 17 -
All Rights Reserved.
T H E P O W E R O F P E R S P E C T I V E
- 18. www.credera.com
Demo Links
Silk Project – MileageStats MVC3 and jQuery demo –
http://silk.codeplex.com
MVC Music Store – an end-to-end MVC3 and EF4.1 Tutorial and
Demo app – http://mvcmusicstore.codeplex.com
Ayende’s Raccoon Blog Engine – open source blog engine using
MVC3 and RavenDB – https://github.com/ayende/raccoonblog
nopCommerce – an open-source e-commerce solution built with
MVC3 – http://www.nopcommerce.com
Orchard CMS – an open-source CMS built using MVC3, by
Microsoft – http://www.orchardproject.net
Copyright © 2011 Credera.
- 18 -
All Rights Reserved.
T H E P O W E R O F P E R S P E C T I V E
- 19. www.credera.com
Final Thoughts…
“ I often find debates around programming model appropriateness and
abstractions a little silly.
Both Web Forms and MVC are programming web framework abstractions,
built on top of a broader framework abstraction, programmed with higher
level programming languages, running on top of a execution engine
abstraction that itself is running on top of a giant abstraction called an
OS.
What you are creating with each is HTML/CSS/JavaScript (all abstractions
persisted as text, transmitted over HTTP – another higher level protocol
abstraction).”
--Scott Guthrie, Corporate VP, Server & Tools Business, Microsoft
http://weblogs.asp.net/scottgu
Copyright © 2011 Credera.
- 19 -
All Rights Reserved.
T H E P O W E R O F P E R S P E C T I V E
- 20. www.credera.com
Credera is a Business and Technology Consulting Firm that Focuses on Leveraging Proven
Technologies to Enable our Clients Business Strategy
Our Company Our People
– Full-service business and technology – Credera’s professionals possess a unique
consulting firm combination of deep technical expertise with
extensive business backgrounds
– Provide business and technology solutions
that offer measurable value to our clients – Backgrounds include business, technology, and
strategy management consulting with some of the
– Deliver value by leveraging our people’s most well-known and respected consulting firms
accumulated industry and management in the world
experience with their deep technical
expertise – Have served many influential corporations in a
variety of industries over the past 20 years
– Established in 1999
– Offices in Dallas, Austin, Denver
Sample Clients
Our Services
– Management Consulting
– Technology Solutions
– Business Intelligence
Copyright © 2011 Credera.
- 20 -
All Rights Reserved.
T H E P O W E R O F P E R S P E C T I V E
- 21. www.credera.com
Coming Up…
Dallas Day of Dot Net
Presents…
Scott Hanselman
March 9-10, 2012
http://dodn2012.eventbrite.com/
Copyright © 2011 Credera.
- 21 -
All Rights Reserved.
T H E P O W E R O F P E R S P E C T I V E
- 22. www.credera.com
Shameless plug…
Buy these!
Copyright © 2011 Credera.
- 22 -
All Rights Reserved.
T H E P O W E R O F P E R S P E C T I V E
- 23. www.credera.com
Q&A
Thank you for attending!
Contact Information:
Thiago Silva
tsilva@credera.com
www.credera.com
Twitter: @tafs7
Blogs: http://blogs.credera.com/
http://silvaware.net
Copyright © 2011 Credera.
- 23 -
All Rights Reserved.
T H E P O W E R O F P E R S P E C T I V E