MVC, MVP and MVVM: A Comparison of Architectural Patterns

  • Published on
    14-Feb-2016

  • View
    66

  • Download
    1

Embed Size (px)

DESCRIPTION

DPR305. MVC, MVP and MVVM: A Comparison of Architectural Patterns. Joe Homnick joe@homnick.com HSI Knowledge. What This Session Is And What It Is Not. It is: An investigation of how different software architecture patterns relate to different Microsoft developer technologies - PowerPoint PPT Presentation

Transcript

<p>DPR305: MVC, MVP and MVVM: A Comparison of Architectural Patterns</p> <p>MVC, MVP and MVVM: A Comparison of Architectural PatternsJoe Homnickjoe@homnick.comHSI KnowledgeDPR3055/16/2011 3:45 PM 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.</p> <p>1What This Session Is And What It Is NotIt is:An investigation of how different software architecture patterns relate to different Microsoft developer technologiesA what to use where discussionIt is not:An exhaustive architectural discussion of software patterns with a bunch of mental pontifications.OverviewWhat, why, how of Model-view-controller(C) or presenter(P) or View Model(VM) architecture patternsModel-View-Controller (MVC) patternASP.Net MVC 3 exampleModel-View-Presenter (MVP) patternWeb Forms/SharePoint exampleModel-View-ViewModel (MVVM) patternSilverlight exampleWhat to use where</p> <p>What is Model/View/(C or VM or P)Patterns that describe a modular approach to software developmentModules include:Model DataView Presentation LayerC or VM or P Glue LogicThey are based upon a Separation of DutiesSeen in many other types o,f system frameworksHow is this different from nTier development in the 90s - anybody remember Distributed interNet Architecture (DNA)Why Model-View-(C or VM or P)The Patterns all have similar goals, however, achieve them in different waysThe Patterns goals are to increase:ModularityFlexibilityTestabilityMaintainability</p> <p>Model-View-Controller (MVC)First described in 1979 for Smalltalk at Xerox PARCController is centerpiece that decouples the Model and ViewControl flow:User interaction eventController handles event and converts it to a user action the Model can understandModel manages the behavior and data of the application domainThe View interacts with the Controller and Model to generate a user interfaceClient/Server (DNA) vs MVCControllerModelViewClient-----------------------Business ObjectsServer-----------------------Business ObjectsDataMVC Observer PatternControllerModelViewdemoASP.Net MVC 35/16/2011 3:45 PM 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.</p> <p>9Model-View-Presenter (MVP)MVP originated in early 1990sMVP is a derivative of MVCTwo types of implementationPassive ViewSupervising ControllerPresenter assumes the functionality of the MVC ControllerView is responsible for handling UI eventsModel becomes strictly a Domain ModelMore User Interface centric</p> <p>MVC vs MVP (Passive)PresenterModelViewControllerModelViewMVP Supervising Controller PatternPresenterModelView12SharePoint 2010 Developer GuidanceMVP Class Diagram and Flow of Execution for the SandBox Execution Model </p> <p>demoMVP Using ASP.Net Web FormsNameTitleGroup5/16/2011 3:45 PM 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.</p> <p>14Model-View-ViewModel (MVVM)Largely based on MVCSpecialization of the MVP pattern known as the Presentation ModelBuilt specifically for the WPF and Silverlight environmentsModel and View works just like MVCViewModel is a Model of the ViewIt extends the Model with Behaviors the View could useData Binding between View and ModelPasses commands between the View and Model</p> <p>MVP (Passive) vs MVVMViewModelModelViewPresenterModelViewdemoMVVM Using SilverlightNameTitleGroup5/16/2011 3:45 PM 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.</p> <p>17What To Use Where</p> <p>Model-View-Controller (MVC) patternASP.Net MVC 3 Disconnected Web Based ApplicationsModel-View-Presenter (MVP) patternWeb Forms/SharePoint, Windows Forms UI state logic already wired upModel-View-ViewModel (MVVM) patternSilverlight, WPFTwo way data-bindingARC Track Resourceshttp://www.microsoft.com/visualstudio http://www.microsoft.com/visualstudio/en-us/lightswitch http://www.microsoft.com/expression/http://blogs.msdn.com/b/somasegar/http://blogs.msdn.com/b/bharry/http://www.microsoft.com/sqlserver/en/us/default.aspxhttp://www.facebook.com/visualstudio </p> <p>Resourceswww.microsoft.com/techedSessions On-Demand &amp; Community</p> <p>Microsoft Certification &amp; Training ResourcesResources for IT ProfessionalsResources for Developerswww.microsoft.com/learning http://microsoft.com/technet http://microsoft.com/msdn </p> <p>Learninghttp://northamerica.msteched.comConnect. Share. Discuss.</p> <p>20Tech Ed North America 20105/16/2011 3:45 PM 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.</p> <p>Complete an evaluation on CommNet and enter to win!</p> <p>21Tech Ed North America 20105/16/2011 3:45 PM 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.</p> <p>Scan the Tag to evaluate this session now on myTechEd Mobile22Tech Ed North America 20105/16/2011 3:45 PM 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.</p> <p>23</p>