23
THE POWER OF PERSPECTIVE ASP.NET MVC vs. Web Forms .NET Track Thiago Silva Credera Copyright © 2011 Credera. All Rights Reserved.

Aspnet mvc vs_web_forms_final

  • Upload
    credera

  • View
    1.333

  • Download
    0

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Aspnet mvc vs_web_forms_final

THE POWER OF PERSPECTIVE

ASP.NET MVC vs. Web Forms .NET Track

Thiago Silva

Credera

Copyright © 2011 Credera. All Rights Reserved.

Page 2: Aspnet mvc vs_web_forms_final

T H E P O W E R O F P E R S P E C T I V E - 2 -

Copyright © 2011 Credera. All Rights Reserved.

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

www.credera.com

Page 3: Aspnet mvc vs_web_forms_final

T H E P O W E R O F P E R S P E C T I V E - 3 -

Copyright © 2011 Credera. All Rights Reserved.

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!

www.credera.com

Page 4: Aspnet mvc vs_web_forms_final

T H E P O W E R O F P E R S P E C T I V E - 4 -

Copyright © 2011 Credera. All Rights Reserved.

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

www.credera.com

Controller

Model View

Page 5: Aspnet mvc vs_web_forms_final

T H E P O W E R O F P E R S P E C T I V E - 5 -

Copyright © 2011 Credera. All Rights Reserved.

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

www.credera.com

Page 6: Aspnet mvc vs_web_forms_final

T H E P O W E R O F P E R S P E C T I V E - 6 -

Copyright © 2011 Credera. All Rights Reserved.

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

www.credera.com

Page 7: Aspnet mvc vs_web_forms_final

T H E P O W E R O F P E R S P E C T I V E - 7 -

Copyright © 2011 Credera. All Rights Reserved.

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

www.credera.com

Page 8: Aspnet mvc vs_web_forms_final

T H E P O W E R O F P E R S P E C T I V E - 8 -

Copyright © 2011 Credera. All Rights Reserved.

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.)

www.credera.com

Page 9: Aspnet mvc vs_web_forms_final

T H E P O W E R O F P E R S P E C T I V E - 9 -

Copyright © 2011 Credera. All Rights Reserved.

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).

www.credera.com

Page 10: Aspnet mvc vs_web_forms_final

T H E P O W E R O F P E R S P E C T I V E - 10 -

Copyright © 2011 Credera. All Rights Reserved.

ASP.NET – The Platform…THEY MEET IN THE MIDDLE!

HTTP Request

HTTP Response

URL Routing

Session State

Caching

Profiles

Security

Membership

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:

Roles

Master Pages

Microsoft ASP.NET AJAX

jQuery

Localization

Configuration

Compilation

Deployment

www.credera.com

Health Monitoring

Process Model

Tracing

Page 11: Aspnet mvc vs_web_forms_final

T H E P O W E R O F P E R S P E C T I V E - 11 -

Copyright © 2011 Credera. All Rights Reserved.

MVC Takes On Web Forms – a Feature Comparison

* 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.

www.credera.com

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

Page 12: Aspnet mvc vs_web_forms_final

T H E P O W E R O F P E R S P E C T I V E - 12 -

Copyright © 2011 Credera. All Rights Reserved.

MVC Takes On Web Forms – Detailed Comparison

www.credera.com

Feature MVC Web Forms

SEO Out of box MVC URLs are SEO friendly

Web Forms can be made to work with friendly URLs by manual processes involving URL rewrites and server transfers

Development Requires more design and separation of concerns, which can be cause for more up from effort, but better long term maintenance

Code-behind is more familiar, and often more easily utilized as the code can directly control page output (e.g. calling a property on a server control)

Separation of Concerns Inherent in the architecture

Can be achieved by diligence and process

Page 13: Aspnet mvc vs_web_forms_final

T H E P O W E R O F P E R S P E C T I V E - 13 -

Copyright © 2011 Credera. All Rights Reserved.

MVC Takes On WebForms – Detailed Comparison

www.credera.com

Feature MVC WebForms

Unit Testing Easy to test the model and controller, as they are de-coupled by the nature of the architecture

More difficult because code-behind is not required to be-decoupled from the form

Open Source Libraries NuGet facilitates easy use of open source, third party libraries, and JavaScript libraries are more easily utilized

Integrating open source, third party libraries is a more manual process

HTML / Page Weight More control over the HTML, easier to build lightweight, HTML compliant pages

More difficult to control HTML because controls and server rendering may be out of developer’s control

Page 14: Aspnet mvc vs_web_forms_final

T H E P O W E R O F P E R S P E C T I V E - 14 -

Copyright © 2011 Credera. All Rights Reserved.

MVC Learning Curve

www.credera.com

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.

Page 15: Aspnet mvc vs_web_forms_final

T H E P O W E R O F P E R S P E C T I V E - 15 -

Copyright © 2011 Credera. All Rights Reserved.

MVC Learning Curve – more stuff

www.credera.com

WebForms Page Lifecycle MVC Page Lifecycle

Page 16: Aspnet mvc vs_web_forms_final

T H E P O W E R O F P E R S P E C T I V E - 16 -

Copyright © 2011 Credera. All Rights Reserved.

MVC Learning Curve – even more stuff

www.credera.com

WebForms

Controls ≈

Code Behind ≈

Events ≈

User Controls ≈

Master Pages =

MVC

Html Helpers

Controller

Routes and Methods

Partial Views

Master Pages and Shared Views

Platform Paradigm Parallels…(say that 5 times in a row!)

Page 17: Aspnet mvc vs_web_forms_final

T H E P O W E R O F P E R S P E C T I V E - 17 -

Copyright © 2011 Credera. All Rights Reserved.

www.credera.com

Demo

Page 18: Aspnet mvc vs_web_forms_final

T H E P O W E R O F P E R S P E C T I V E - 18 -

Copyright © 2011 Credera. All Rights Reserved.

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

Page 19: Aspnet mvc vs_web_forms_final

T H E P O W E R O F P E R S P E C T I V E - 19 -

Copyright © 2011 Credera. All Rights Reserved.

Final Thoughts…

www.credera.com

“ 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

Page 20: Aspnet mvc vs_web_forms_final

T H E P O W E R O F P E R S P E C T I V E - 20 -

Copyright © 2011 Credera. All Rights Reserved.

Our Company

– Full-service business and technology consulting firm

– Provide business and technology solutions that offer measurable value to our clients

– Deliver value by leveraging our people’s accumulated industry and management experience with their deep technical expertise

– Established in 1999

– Offices in Dallas, Austin, Denver

Our Services

– Management Consulting

– Technology Solutions

– Business Intelligence

Our People

– Credera’s professionals possess a unique combination of deep technical expertise with extensive business backgrounds

– Backgrounds include business, technology, and strategy management consulting with some of the most well-known and respected consulting firms in the world

– Have served many influential corporations in a variety of industries over the past 20 years

Sample Clients

Credera is a Business and Technology Consulting Firm that Focuses on Leveraging Proven Technologies to Enable our Clients Business Strategy

www.credera.com

Page 21: Aspnet mvc vs_web_forms_final

T H E P O W E R O F P E R S P E C T I V E - 21 -

Copyright © 2011 Credera. All Rights Reserved.

Coming Up…

www.credera.com

Dallas Day of Dot Net Presents…

Scott

Hanselman

March 9-10, 2012

http://dodn2012.eventbrite.com/

Page 22: Aspnet mvc vs_web_forms_final

T H E P O W E R O F P E R S P E C T I V E - 22 -

Copyright © 2011 Credera. All Rights Reserved.

Shameless plug…

www.credera.com

Buy these!

Page 23: Aspnet mvc vs_web_forms_final

T H E P O W E R O F P E R S P E C T I V E - 23 -

Copyright © 2011 Credera. All Rights Reserved.

Q&A

www.credera.com

Thank you for attending!

Contact Information:

Thiago Silva

[email protected]

www.credera.com

Twitter: @tafs7

Blogs: http://blogs.credera.com/

http://silvaware.net