1 / 39

MVC – What’s all the fuss?

ASP.NET Web Forms. ASP.NET MVC. MVC – What’s all the fuss?. Presented by @ EricPhan – Solution Architect @ SSW. Eric Phan – SA @ SSW. w: ericphan.info | e: EricPhan @ssw.com.au | t: @ ericphan. Application architecture SQL Performance Tuning Certified Scrum Master

nita
Download Presentation

MVC – What’s all the fuss?

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ASP.NET Web Forms ASP.NET MVC MVC – What’s all the fuss? Presented by @EricPhan – Solution Architect @ SSW Delivering Awesome Web Applications

  2. Eric Phan – SA @ SSW w: ericphan.info | e: EricPhan@ssw.com.au | t: @ericphan • Application architecture • SQL Performance Tuning • Certified Scrum Master • Technology aficionado • Silverlight (RIP) • Windows Forms (RIP) • ASP.NET + MVC • CRM • Business Intelligence

  3. Agenda A brief history of the Microsoft web platform • ASP Classic • ASP.NET Web Forms • ASP.NET MVC Why clients and devs choose MVC Common MVC questions • Third Party Tools • Learning Curve • Migration Q&A

  4. It was VB scripting for the web • Does the term spaghetti coding ring a bell? • ActiveX and COM hell • Deployments/Updates usually involved stopping IIS • Avert your eyes now… <%Response.Write("<h1>Multiplication table</h1>")Response.Write("<table border=2 width=50%") Fori = 1 to 9             response.write("<tr>")response.write("<td>" & i & "</td>")For j = 2 to 9          response.write("<td>" & i * j & "</td>")Nextresponse.write("</tr>")Nextresponse.write("</table>") %>

  5. Problems with Classic ASP • Interpreted (more runtime errors) • Testing was Edit, Save, Load Page, rinse and repeat • Logic and UI on a single page • If you wanted to move logic out you created COM objects • Poor performance • Poor architecture (1 tiered)

  6. Windows Forms for the Web • Separated the HTML from the Server Side Code (*.aspx, *.aspx.cs, *.aspx.vb) • Compiled & Strongly typed • Better performance • Xcopy deployment • Better performance • C# Support!!! • New features: • Event Driven • Caching • Server side controls • Data binding • Web Services • State Management • Drag and drop controls

  7. Problems with ASP.NET Web Forms • Gigantic View State • False sense of separation of UI and Code • Difficult to write unit tests against the web project • Limited control of the HTML output • URLs • Dodgy designer • In depth knowledge of the Page Lifecycle

  8. View and code separation out of the box • Shorter pipeline/life cycle • Fully unit testable • Full control over HTML output • SEO friendly URLs • Small footprint • Web API • JSON support • NuGet • Mobile targeting • Bundling + Minification • Extensible – Don’t like Razor? Write your own view engine • Convention over configuration

  9. Problems with ASP.NET MVC • Initial cost of the first page • Lots of conventions • Fingers get good exercise  • No Designer

  10. MVC Life cycle

  11. <table> <thead> <trclass="thead"> <th>Distributor</th> <th>Account Code</th> <th>Name</th> <th>Address</th> <th>Terminal ID</th> <th></th> </tr> </thead> @foreach (var item inModel.Customers) { <tr> <td>@Html.DisplayFor(modelItem => item.Distributor)</td> <td>@Html.DisplayFor(modelItem => item.AccountCode)</td> <td>@Html.DisplayFor(modelItem => item.Name)</td> <td>@(item.Address == ", -1" ? "" : item.Address)</td> <td>@Html.DisplayFor(modelItem => item.TerminalId)</td> <td>@Html.ActionLink(item.Links > 0 ? "Edit (" + item.Links + ")" : "Assign", "Edit", new { id = item.CustomerId })</td> </tr> }

  12. <table> <thead> <trclass="thead"> <th>Distributor</th> <th>Account Code</th> <th>Name</th> <th>Address</th> <th>Terminal ID</th> <th></th> </tr> </thead> @foreach (var item inModel.Customers) { <tr> <td>@Html.DisplayFor(modelItem => item.Distributor)</td> <td>@Html.DisplayFor(modelItem => item.AccountCode)</td> <td>@Html.DisplayFor(modelItem => item.Name)</td> <td>@(item.Address == ", -1" ? "" : item.Address)</td> <td>@Html.DisplayFor(modelItem => item.TerminalId)</td> <td>@Html.ActionLink(item.Links > 0 ? "Edit (" + item.Links + ")" : "Assign", "Edit", new { id = item.CustomerId })</td> </tr> }

  13. Nice URLs SharePoint 2010 Document Library http://sharepoint.ssw.com.au/Training/UTSSQL/Documents/Forms/AllItems.aspx?RootFolder=%2FTraining%2FUTSSQL%2FDocuments%2FLatest&FolderCTID=0x0120002E151A03AD819A4D8F3C2EE85587E36E&View={A8CF0D12-F1EC-401B-B48A-E135549EB5C4} MVC – SSW TimePro https://timepro.ssw.com.au/Timesheet/EP https://timepro.ssw.com.au/Timesheet/EP/Week https://timepro.ssw.com.au/Timesheet/EP/2012-05-29/Add https://timepro.ssw.com.au/Account/Settings https://timepro.ssw.com.au/Report/MissingTimesheets/2012-5-28

  14. View State

  15. ALL JUNK – About 8000 bytes The relevant data

  16. The relevant data – Request 400 bytes

  17. Some feedback from developers

  18. Some statistics http://trends.builtwith.com/framework/ASP.NET

  19. Some statistics http://trends.builtwith.com/framework/ASP.NET-MVC

  20. Jobs http://www.indeed.com/jobanalytics/jobtrends?q=asp.net&l=

  21. Jobs http://www.indeed.com/jobtrends?q=mvc&l=

  22. MVC Adoption • All our greenfield projects are MVC unless: • We are integrating with some framework (e.g. CMS system) • Developers generally fall in love with MVC once they start using it • On the cusp of a sea change

  23. MVC Features • Web API – RESTful services with little effort • URL routing & Managed URLs (can be used with ASP.NET WebForms) • Filters (easily add error handling and logging) • Content bundling • Sections • NuGet • Mobile targeting • Open Source • Features developed for MVC then ported back to ASP.NET (URL)

  24. Awesome NuGet Packages • Glimpse • MobileViewEngines (MVC3, built into MVC4) • MiniProfiler • MvcMailer • MvcDonutCaching

  25. Common Questions • Third Party Controls? • Telerik • MVC Toolkit • Infragistics • ComponentArt • ComponentOne • Javascript based: • jQuery + jQueryUI (bundled) • KendoUI • KnockoutJS • Twitter Bootstrap

  26. Common Questions • Migrating from ASP.NET? • Run MVC & Web Forms side by side • Just migrate new functionality to MVC • Migrate any page that you touch to MVC

  27. Common Questions • Learning curve? • Statelessness • Lots more jQuery • Raw HTML • Conventions (more files, View, Model, Controller, Display and EditorTemplates) • Allow a couple of months to become comfortable

  28. So ASP.NET or MVC? http://programmers.stackexchange.com/questions/95212/when-to-favor-webforms-over-mvc

  29. Want to learn more about ASP.NET MVC? • ASP.NET MVC • http://www.asp.net/mvc/mvc4 • A look at ASP.NET MVC 4 - Scott Guthrie • http://channel9.msdn.com/Events/TechDays/Techdays-2012-the-Netherlands/2364 • Zero to Everywhere with ASP.NET MVC – Damian Brady • http://r.ssw.com/mvc-mobile

  30. MVC Courses • MVC for Enterprise Apps Part I - $330 + GST • http://r.ssw.com/mvc-1 • Free license: • Kendo UI - $399 • Just Code - $249 • MVC for Enterprise Apps Part II - $330 + GST • http://r.ssw.com/mvc-2

  31. Your Questions?

  32. 3things… • EricPhan@ssw.com.au • http://ericphan.info/ • twitter.com/ericphan

  33. Thank You! Sydney | Melbourne | Brisbane | Adelaide info@ssw.com.au www.ssw.com.au

More Related