dpr305. controller model view client ----------------------- business objects server...

23
MVC, MVP and MVVM: A Comparison of Architectural Patterns Joe Homnick [email protected] HSI Knowledge DPR305

Upload: barry-mcdowell

Post on 03-Jan-2016

225 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: DPR305. Controller Model View Client ----------------------- Business Objects Server ----------------------- Business Objects Data

MVC, MVP and MVVM: A Comparison of Architectural PatternsJoe [email protected] Knowledge

DPR305

Page 2: DPR305. Controller Model View Client ----------------------- Business Objects Server ----------------------- Business Objects Data

What This Session Is And What It Is Not

It is:An investigation of how different software architecture patterns relate to different Microsoft developer technologiesA what to use where discussion

It is not:An exhaustive architectural discussion of software patterns with a bunch of mental pontifications.

Page 3: DPR305. Controller Model View Client ----------------------- Business Objects Server ----------------------- Business Objects Data

Overview

What, why, how of Model-view-controller(C) or presenter(P) or View Model(VM) architecture patternsModel-View-Controller (MVC) pattern

ASP.Net MVC 3 example

Model-View-Presenter (MVP) patternWeb Forms/SharePoint example

Model-View-ViewModel (MVVM) patternSilverlight example

What to use where

Page 4: DPR305. Controller Model View Client ----------------------- Business Objects Server ----------------------- Business Objects Data

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 Logic

They are based upon a “Separation of Duties”Seen in many other types o,f system frameworks

How is this different from nTier development in the 90’s - anybody remember Distributed interNet Architecture (DNA)

Page 5: DPR305. Controller Model View Client ----------------------- Business Objects Server ----------------------- Business Objects Data

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

Page 6: DPR305. Controller Model View Client ----------------------- Business Objects Server ----------------------- Business Objects Data

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 interface

Page 7: DPR305. Controller Model View Client ----------------------- Business Objects Server ----------------------- Business Objects Data

Client/Server (DNA) vs MVC

Controller

ModelView

Client-----------------------

Business Objects

Server-----------------------Business Objects

Data

Page 8: DPR305. Controller Model View Client ----------------------- Business Objects Server ----------------------- Business Objects Data

MVC Observer Pattern

Controller

ModelView

Page 9: DPR305. Controller Model View Client ----------------------- Business Objects Server ----------------------- Business Objects Data

demo

ASP.Net MVC 3

Page 10: DPR305. Controller Model View Client ----------------------- Business Objects Server ----------------------- Business Objects Data

Model-View-Presenter (MVP)

MVP originated in early 1990sMVP is a derivative of MVCTwo types of implementation

Passive ViewSupervising Controller

Presenter assumes the functionality of the MVC ControllerView is responsible for handling UI eventsModel becomes strictly a Domain ModelMore User Interface centric

Page 11: DPR305. Controller Model View Client ----------------------- Business Objects Server ----------------------- Business Objects Data

MVC vs MVP (Passive)

Presenter

ModelView

Controller

ModelView

Page 12: DPR305. Controller Model View Client ----------------------- Business Objects Server ----------------------- Business Objects Data

MVP – Supervising Controller Pattern

Presenter

ModelView

Page 13: DPR305. Controller Model View Client ----------------------- Business Objects Server ----------------------- Business Objects Data

SharePoint 2010 Developer Guidance

MVP Class Diagram and Flow of Execution for the SandBox Execution Model

Page 14: DPR305. Controller Model View Client ----------------------- Business Objects Server ----------------------- Business Objects Data

demo

MVP Using ASP.Net Web Forms

NameTitleGroup

Page 15: DPR305. Controller Model View Client ----------------------- Business Objects Server ----------------------- Business Objects Data

Model-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 View”

It extends the Model with Behaviors the View could useData Binding between View and ModelPasses commands between the View and Model

Page 16: DPR305. Controller Model View Client ----------------------- Business Objects Server ----------------------- Business Objects Data

MVP (Passive) vs MVVM

ViewModel

ModelView

Presenter

ModelView

Page 17: DPR305. Controller Model View Client ----------------------- Business Objects Server ----------------------- Business Objects Data

demo

MVVM Using Silverlight

NameTitleGroup

Page 18: DPR305. Controller Model View Client ----------------------- Business Objects Server ----------------------- Business Objects Data

What To Use Where

Model-View-Controller (MVC) patternASP.Net MVC 3 Disconnected Web Based Applications

Model-View-Presenter (MVP) patternWeb Forms/SharePoint, Windows Forms UI state logic already wired up

Model-View-ViewModel (MVVM) patternSilverlight, WPFTwo way data-binding

Page 19: DPR305. Controller Model View Client ----------------------- Business Objects Server ----------------------- Business Objects Data

ARC Track Resources

http://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

Page 20: DPR305. Controller Model View Client ----------------------- Business Objects Server ----------------------- Business Objects Data

Resources

www.microsoft.com/teched

Sessions On-Demand & Community Microsoft Certification & Training Resources

Resources for IT Professionals Resources for Developers

www.microsoft.com/learning

http://microsoft.com/technet http://microsoft.com/msdn

Learning

http://northamerica.msteched.com

Connect. Share. Discuss.

Page 21: DPR305. Controller Model View Client ----------------------- Business Objects Server ----------------------- Business Objects Data

Complete an evaluation on CommNet and enter to win!

Page 22: DPR305. Controller Model View Client ----------------------- Business Objects Server ----------------------- Business Objects Data

Scan the Tag to evaluate this session now on myTech•Ed Mobile

Page 23: DPR305. Controller Model View Client ----------------------- Business Objects Server ----------------------- Business Objects Data