SlideShare ist ein Scribd-Unternehmen logo
1 von 23
Code Camp 06’ Presentation – Model View Presenter Design and Implementation Chase Thomas Consultant - MCSD.NET - Digineer Inc.
Model View Presenter Architecture The Model View Presenter is a user interface architecture similar in nature to the model view controller.  One of the greatest strengths in the MVP design is the ability to unit test user interface logic without a user interface. It’s origins are from the Taligent programming model for C++ and Java (based on the Smalltalk MVC) and has seen various implementations since it’s introduction. You can read more about the origins of MVP at the following URLs… ftp://www6.software.ibm.com/software/developer/library/mvp.pdf http://www.object-arts.com/papers/TwistingTheTriad.PDF
Model View Presenter Architecture Traditionally The View has a dependency on the model. The view directly interacts with the Model and the controller directly interacts with the view – controlling complex UI logic and data mapping. Classic Model View Controller (MVC) Architecture.
Model View Presenter Architecture ,[object Object],[object Object],[object Object],[object Object]
Model View Presenter Architecture ,[object Object],[object Object],[object Object],[object Object],[object Object]
Model View Presenter Architecture Model View Presenter (MVP) ,[object Object],[object Object],[object Object],[object Object],[object Object]
Model View Presenter Architecture Architecture UML (Class Diagram)
Model View Presenter Architecture Architecture UML Diagram (Sequence – Loading an Employee Model)
Model View Presenter Architecture Architecture UML Diagram (Sequence – Changing a value in the UI)
Model View Presenter Architecture Implementation in C# (.NET 2.0) Building the model objects The core responsibility of the Model within and MVP is notifying the presenter of changes and managing it’s own data access and validation. ,[object Object],[object Object],[object Object],Implementation of the  INotifyPropertyChanged  interface (part of the System.ComponentModel namespace) is another option that works if you want to roll your own solution for the Model.
Model View Presenter Architecture Implementation in C# (.NET 2.0) Building the model objects – Using Gestalt
Model View Presenter Architecture Implementation in C# (.NET 2.0) Building the model objects – Using CSLA.NET
Model View Presenter Architecture Implementation in C# (.NET 2.0) Building the model objects – Simple INotifyPropertyChanged Interface Implementation
Model View Presenter Architecture Implementation in C# (.NET 2.0) Defining Our Interfaces… Every view needs to have an interface that will be used by the presenter to interact with it. ,[object Object],[object Object],[object Object],[object Object]
Model View Presenter Architecture Implementation in C# (.NET 2.0) Defining Our Interfaces – IEmployeeView Interface
Model View Presenter Architecture Implementation in C# (.NET 2.0) Building the Presenter… What needs to happen here… ,[object Object],[object Object],[object Object],[object Object]
Model View Presenter Architecture Implementation in C# (.NET 2.0) Implementing our View Interface  (part one – the Windows Form)… Implement the IEmployeeView interface on the windows form – the windows form implementation will receive information from the presenter and utilize it to perform display tasks.
Model View Presenter Architecture Implementation in C# (.NET 2.0) Implementing our View Interface  (part two – the UI Unit Tests)… Implement the IEmployeeView interface on the unit test class that has the TestFixture attribute applied.  Within the unit test class you will need to create placeholder values for what the windows form user interface state (i.e. control colors – error messages – enabled / disabled state etc…).  The unit test in essence becomes a Windows Form simulator.  If you did it right – there will be nothing missed by using a Unit test in place of a windows form.
Model View Presenter Architecture “ Blind Data binding” Problem: Since the view knows nothing about the model – how can we bind the view to our objects? Solution: Create a windows custom binding source object pass the binding source object to our presenter. Finally: Once the presenter has a reference to the windows forms Binding Source - establish the data bindings between the controls and the object in our form code.
Model View Presenter Architecture Implementation of “Blind Data binding” in C# (.NET 2.0) Create and pass our binding source to the presenter
Model View Presenter Architecture Implementation of “Blind Data binding” in C# (.NET 2.0) Establishing the Data bindings from our view The one of the cardinal rules of the MVP is that the View cannot know about or have a reference to the Model. That does not mean we can’t look at our Model property names and set up bindings in the form.  We have not retained any knowledge of the Model within our presenter by doing this – just string values – you could even keep these values as constants in the presenter to centralize the information.
Model View Presenter Architecture What is the Supervising Controller and Passive View? http://www.martinfowler.com/eaaDev/SupervisingPresenter.html The 10 second description of these two derivations of the MVP are that they vary in how much interaction the view has with the model. In a supervising presenter the model is exposed to the view in order to perform data binding or other simple data to UI mapping. http://www.martinfowler.com/eaaDev/PassiveScreen.html A passive view is closer to what we just discussed with the original MVP.  The view has no dependence on the Model whatsoever.  The presenter handles all data mapping between the UI and Model To describe these two “new” concepts is beyond the scope of this presentation – however since they are now the recommended approaches according to Fowler’s website, a brief explanation of the two are in order…
Model View Presenter Architecture Sources of Material http://www.martinfowler.com/eaaDev/uiArchs.html http://www.martinfowler.com/eaaDev/SupervisingPresenter.html http://www.martinfowler.com/eaaDev/PassiveScreen.html http://msdn.microsoft.com/msdnmag/issues/06/08/DesignPatterns/

Weitere ähnliche Inhalte

Was ist angesagt?

MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )Ahmed Emad
 
Dynamic and Generic Manipulation of Models: From Introspection to Scripting
Dynamic and Generic Manipulation of Models: From Introspection to ScriptingDynamic and Generic Manipulation of Models: From Introspection to Scripting
Dynamic and Generic Manipulation of Models: From Introspection to Scriptingvanwormhoudt
 
Design pattern in android
Design pattern in androidDesign pattern in android
Design pattern in androidJay Kumarr
 
Design Pattern - MVC, MVP and MVVM
Design Pattern - MVC, MVP and MVVMDesign Pattern - MVC, MVP and MVVM
Design Pattern - MVC, MVP and MVVMMudasir Qazi
 
MVC for Desktop Application - Part 4
MVC for Desktop Application - Part 4MVC for Desktop Application - Part 4
MVC for Desktop Application - Part 4晟 沈
 
MVC for Desktop Application - Part 2
MVC for Desktop Application - Part  2MVC for Desktop Application - Part  2
MVC for Desktop Application - Part 2晟 沈
 
MVC for Desktop Application - Part 3
MVC for Desktop Application - Part 3MVC for Desktop Application - Part 3
MVC for Desktop Application - Part 3晟 沈
 
Advanced java lab swing mvc awt
Advanced java lab swing mvc awtAdvanced java lab swing mvc awt
Advanced java lab swing mvc awtvishal choudhary
 
AngularJS: Overview & Key Features
AngularJS: Overview & Key FeaturesAngularJS: Overview & Key Features
AngularJS: Overview & Key FeaturesMohamad Al Asmar
 
MVC for Desktop Application - Part 1
MVC for Desktop Application - Part 1MVC for Desktop Application - Part 1
MVC for Desktop Application - Part 1晟 沈
 
Stephen Kennedy Silverlight 3 Deep Dive
Stephen Kennedy Silverlight 3 Deep DiveStephen Kennedy Silverlight 3 Deep Dive
Stephen Kennedy Silverlight 3 Deep DiveMicrosoftFeed
 
Factory method pattern (Virtual Constructor)
Factory method pattern (Virtual Constructor)Factory method pattern (Virtual Constructor)
Factory method pattern (Virtual Constructor)Sameer Rathoud
 
introduction to Angularjs basics
introduction to Angularjs basicsintroduction to Angularjs basics
introduction to Angularjs basicsRavindra K
 
ASP.NET MVC Presentation
ASP.NET MVC PresentationASP.NET MVC Presentation
ASP.NET MVC PresentationVolkan Uzun
 
ASP.NET MVC.
ASP.NET MVC.ASP.NET MVC.
ASP.NET MVC.Ni
 

Was ist angesagt? (20)

Building richwebapplicationsusingasp
Building richwebapplicationsusingaspBuilding richwebapplicationsusingasp
Building richwebapplicationsusingasp
 
MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )
 
Dynamic and Generic Manipulation of Models: From Introspection to Scripting
Dynamic and Generic Manipulation of Models: From Introspection to ScriptingDynamic and Generic Manipulation of Models: From Introspection to Scripting
Dynamic and Generic Manipulation of Models: From Introspection to Scripting
 
Design pattern in android
Design pattern in androidDesign pattern in android
Design pattern in android
 
Why MVC?
Why MVC?Why MVC?
Why MVC?
 
Design Pattern - MVC, MVP and MVVM
Design Pattern - MVC, MVP and MVVMDesign Pattern - MVC, MVP and MVVM
Design Pattern - MVC, MVP and MVVM
 
MVC for Desktop Application - Part 4
MVC for Desktop Application - Part 4MVC for Desktop Application - Part 4
MVC for Desktop Application - Part 4
 
MVC for Desktop Application - Part 2
MVC for Desktop Application - Part  2MVC for Desktop Application - Part  2
MVC for Desktop Application - Part 2
 
MVC for Desktop Application - Part 3
MVC for Desktop Application - Part 3MVC for Desktop Application - Part 3
MVC for Desktop Application - Part 3
 
Advanced java lab swing mvc awt
Advanced java lab swing mvc awtAdvanced java lab swing mvc awt
Advanced java lab swing mvc awt
 
AngularJS: Overview & Key Features
AngularJS: Overview & Key FeaturesAngularJS: Overview & Key Features
AngularJS: Overview & Key Features
 
MVC for Desktop Application - Part 1
MVC for Desktop Application - Part 1MVC for Desktop Application - Part 1
MVC for Desktop Application - Part 1
 
MVVM In Use
MVVM In UseMVVM In Use
MVVM In Use
 
Stephen Kennedy Silverlight 3 Deep Dive
Stephen Kennedy Silverlight 3 Deep DiveStephen Kennedy Silverlight 3 Deep Dive
Stephen Kennedy Silverlight 3 Deep Dive
 
Factory method pattern (Virtual Constructor)
Factory method pattern (Virtual Constructor)Factory method pattern (Virtual Constructor)
Factory method pattern (Virtual Constructor)
 
introduction to Angularjs basics
introduction to Angularjs basicsintroduction to Angularjs basics
introduction to Angularjs basics
 
ASP.NET MVC Presentation
ASP.NET MVC PresentationASP.NET MVC Presentation
ASP.NET MVC Presentation
 
ASP.NET MVC3 RAD
ASP.NET MVC3 RADASP.NET MVC3 RAD
ASP.NET MVC3 RAD
 
Why Use MVC?
Why Use MVC?Why Use MVC?
Why Use MVC?
 
ASP.NET MVC.
ASP.NET MVC.ASP.NET MVC.
ASP.NET MVC.
 

Andere mochten auch

Edisi2novaceh
Edisi2novacehEdisi2novaceh
Edisi2novacehepaper
 
Edisi 22 Maret Aceh
Edisi 22 Maret AcehEdisi 22 Maret Aceh
Edisi 22 Maret Acehepaper
 
2016 cornerstone Chapter Leaders Conference
2016 cornerstone Chapter Leaders Conference2016 cornerstone Chapter Leaders Conference
2016 cornerstone Chapter Leaders ConferenceTim Richardson
 
Building On Services Characteristics To Develop Successful
Building On Services Characteristics To Develop SuccessfulBuilding On Services Characteristics To Develop Successful
Building On Services Characteristics To Develop Successfulmvkchaitanya
 
Edisi 3 April Aceh
Edisi 3 April AcehEdisi 3 April Aceh
Edisi 3 April Acehepaper
 
Edisi 4 April Nusantara
Edisi 4 April NusantaraEdisi 4 April Nusantara
Edisi 4 April Nusantaraepaper
 
Edisi 6 Maret Nas
Edisi 6 Maret NasEdisi 6 Maret Nas
Edisi 6 Maret Nasepaper
 
Formation of the Grand Canyon Starter
Formation of the Grand Canyon StarterFormation of the Grand Canyon Starter
Formation of the Grand Canyon Starterdouglasgreig
 
8mei nas
8mei nas8mei nas
8mei nasepaper
 
The Broadcasters - Ch 4 and 5
The Broadcasters - Ch 4 and 5 The Broadcasters - Ch 4 and 5
The Broadcasters - Ch 4 and 5 Jill Falk
 
Edisi12oktnasional
Edisi12oktnasionalEdisi12oktnasional
Edisi12oktnasionalepaper
 
Edisi19aceh
Edisi19acehEdisi19aceh
Edisi19acehepaper
 
10desnasyg Bner
10desnasyg Bner10desnasyg Bner
10desnasyg Bnerepaper
 
Is the grass greener in ireland? A comparison of UX in Dublin and Melbourne
Is the grass greener in ireland? A comparison of UX in Dublin and MelbourneIs the grass greener in ireland? A comparison of UX in Dublin and Melbourne
Is the grass greener in ireland? A comparison of UX in Dublin and MelbourneCory-Ann Joseph
 
Edisi2novnas
Edisi2novnasEdisi2novnas
Edisi2novnasepaper
 
8juni nas
8juni nas8juni nas
8juni nasepaper
 
30jun aceh
30jun aceh30jun aceh
30jun acehepaper
 
NERD meets NIF: Lifting NLP Extraction Results to the Linked Data Cloud
NERD meets NIF:  Lifting NLP Extraction Results to the Linked Data CloudNERD meets NIF:  Lifting NLP Extraction Results to the Linked Data Cloud
NERD meets NIF: Lifting NLP Extraction Results to the Linked Data CloudGiuseppe Rizzo
 

Andere mochten auch (20)

Edisi2novaceh
Edisi2novacehEdisi2novaceh
Edisi2novaceh
 
Edisi 22 Maret Aceh
Edisi 22 Maret AcehEdisi 22 Maret Aceh
Edisi 22 Maret Aceh
 
2016 cornerstone Chapter Leaders Conference
2016 cornerstone Chapter Leaders Conference2016 cornerstone Chapter Leaders Conference
2016 cornerstone Chapter Leaders Conference
 
Building On Services Characteristics To Develop Successful
Building On Services Characteristics To Develop SuccessfulBuilding On Services Characteristics To Develop Successful
Building On Services Characteristics To Develop Successful
 
Edisi 3 April Aceh
Edisi 3 April AcehEdisi 3 April Aceh
Edisi 3 April Aceh
 
Edisi 4 April Nusantara
Edisi 4 April NusantaraEdisi 4 April Nusantara
Edisi 4 April Nusantara
 
Edisi 6 Maret Nas
Edisi 6 Maret NasEdisi 6 Maret Nas
Edisi 6 Maret Nas
 
Formation of the Grand Canyon Starter
Formation of the Grand Canyon StarterFormation of the Grand Canyon Starter
Formation of the Grand Canyon Starter
 
8mei nas
8mei nas8mei nas
8mei nas
 
The Broadcasters - Ch 4 and 5
The Broadcasters - Ch 4 and 5 The Broadcasters - Ch 4 and 5
The Broadcasters - Ch 4 and 5
 
Edisi12oktnasional
Edisi12oktnasionalEdisi12oktnasional
Edisi12oktnasional
 
Edisi19aceh
Edisi19acehEdisi19aceh
Edisi19aceh
 
Letter Writers
Letter WritersLetter Writers
Letter Writers
 
10desnasyg Bner
10desnasyg Bner10desnasyg Bner
10desnasyg Bner
 
Is the grass greener in ireland? A comparison of UX in Dublin and Melbourne
Is the grass greener in ireland? A comparison of UX in Dublin and MelbourneIs the grass greener in ireland? A comparison of UX in Dublin and Melbourne
Is the grass greener in ireland? A comparison of UX in Dublin and Melbourne
 
Kilifi Pictures
Kilifi  PicturesKilifi  Pictures
Kilifi Pictures
 
Edisi2novnas
Edisi2novnasEdisi2novnas
Edisi2novnas
 
8juni nas
8juni nas8juni nas
8juni nas
 
30jun aceh
30jun aceh30jun aceh
30jun aceh
 
NERD meets NIF: Lifting NLP Extraction Results to the Linked Data Cloud
NERD meets NIF:  Lifting NLP Extraction Results to the Linked Data CloudNERD meets NIF:  Lifting NLP Extraction Results to the Linked Data Cloud
NERD meets NIF: Lifting NLP Extraction Results to the Linked Data Cloud
 

Ähnlich wie Code Camp 06 Model View Presenter Architecture

Ppt of Basic MVC Structure
Ppt of Basic MVC StructurePpt of Basic MVC Structure
Ppt of Basic MVC StructureDipika Wadhvani
 
MVC(Model View Controller),Web,Enterprise,Mobile
MVC(Model View Controller),Web,Enterprise,MobileMVC(Model View Controller),Web,Enterprise,Mobile
MVC(Model View Controller),Web,Enterprise,Mobilenaral
 
MVVM presentation
MVVM presentationMVVM presentation
MVVM presentationInova LLC
 
Architectural Design Pattern: Android
Architectural Design Pattern: AndroidArchitectural Design Pattern: Android
Architectural Design Pattern: AndroidJitendra Kumar
 
Android DesignArchitectures.pptx
Android DesignArchitectures.pptxAndroid DesignArchitectures.pptx
Android DesignArchitectures.pptxSafnaSaff1
 
Mvvw patterns
Mvvw patternsMvvw patterns
Mvvw patternseleksdev
 
Mvc vs mvp vs mvvm a guide on architecture presentation patterns
Mvc vs mvp vs mvvm  a guide on architecture presentation patternsMvc vs mvp vs mvvm  a guide on architecture presentation patterns
Mvc vs mvp vs mvvm a guide on architecture presentation patternsConcetto Labs
 
Task 2 - Educational Article – Model View Controller (MVC)
Task 2 - Educational Article – Model View Controller (MVC)Task 2 - Educational Article – Model View Controller (MVC)
Task 2 - Educational Article – Model View Controller (MVC)Shubham Goenka
 
SUE AGILE MVVM (English)
SUE AGILE MVVM (English)SUE AGILE MVVM (English)
SUE AGILE MVVM (English)Sabino Labarile
 
Models used in iOS programming, with a focus on MVVM
Models used in iOS programming, with a focus on MVVMModels used in iOS programming, with a focus on MVVM
Models used in iOS programming, with a focus on MVVMAndrei Popa
 
MVC Pattern. Flex implementation of MVC
MVC Pattern. Flex implementation of MVCMVC Pattern. Flex implementation of MVC
MVC Pattern. Flex implementation of MVCAnton Krasnoshchok
 
IRJET- MVC Framework: A Modern Web Application Development Approach and Working
IRJET- MVC Framework: A Modern Web Application Development Approach and WorkingIRJET- MVC Framework: A Modern Web Application Development Approach and Working
IRJET- MVC Framework: A Modern Web Application Development Approach and WorkingIRJET Journal
 
MVC Architecture: A Detailed Insight to the Modern Web Applications Developme...
MVC Architecture: A Detailed Insight to the Modern Web Applications Developme...MVC Architecture: A Detailed Insight to the Modern Web Applications Developme...
MVC Architecture: A Detailed Insight to the Modern Web Applications Developme...CrimsonpublishersPRSP
 
MVVM Design Pattern NDC2009
MVVM Design Pattern NDC2009MVVM Design Pattern NDC2009
MVVM Design Pattern NDC2009Jonas Follesø
 
Pattern oriented architecture for web based architecture
Pattern oriented architecture for web based architecturePattern oriented architecture for web based architecture
Pattern oriented architecture for web based architectureshuchi tripathi
 

Ähnlich wie Code Camp 06 Model View Presenter Architecture (20)

Ppt of Basic MVC Structure
Ppt of Basic MVC StructurePpt of Basic MVC Structure
Ppt of Basic MVC Structure
 
IntroductionToMVC
IntroductionToMVCIntroductionToMVC
IntroductionToMVC
 
MVC(Model View Controller),Web,Enterprise,Mobile
MVC(Model View Controller),Web,Enterprise,MobileMVC(Model View Controller),Web,Enterprise,Mobile
MVC(Model View Controller),Web,Enterprise,Mobile
 
MVVM presentation
MVVM presentationMVVM presentation
MVVM presentation
 
Architectural Design Pattern: Android
Architectural Design Pattern: AndroidArchitectural Design Pattern: Android
Architectural Design Pattern: Android
 
Android DesignArchitectures.pptx
Android DesignArchitectures.pptxAndroid DesignArchitectures.pptx
Android DesignArchitectures.pptx
 
Mvc
MvcMvc
Mvc
 
Mvvw patterns
Mvvw patternsMvvw patterns
Mvvw patterns
 
Mvc vs mvp vs mvvm a guide on architecture presentation patterns
Mvc vs mvp vs mvvm  a guide on architecture presentation patternsMvc vs mvp vs mvvm  a guide on architecture presentation patterns
Mvc vs mvp vs mvvm a guide on architecture presentation patterns
 
Task 2 - Educational Article – Model View Controller (MVC)
Task 2 - Educational Article – Model View Controller (MVC)Task 2 - Educational Article – Model View Controller (MVC)
Task 2 - Educational Article – Model View Controller (MVC)
 
MVC in PHP
MVC in PHPMVC in PHP
MVC in PHP
 
SUE AGILE MVVM (English)
SUE AGILE MVVM (English)SUE AGILE MVVM (English)
SUE AGILE MVVM (English)
 
Models used in iOS programming, with a focus on MVVM
Models used in iOS programming, with a focus on MVVMModels used in iOS programming, with a focus on MVVM
Models used in iOS programming, with a focus on MVVM
 
MVC Pattern. Flex implementation of MVC
MVC Pattern. Flex implementation of MVCMVC Pattern. Flex implementation of MVC
MVC Pattern. Flex implementation of MVC
 
Design Pattern
Design PatternDesign Pattern
Design Pattern
 
Design pattern
Design patternDesign pattern
Design pattern
 
IRJET- MVC Framework: A Modern Web Application Development Approach and Working
IRJET- MVC Framework: A Modern Web Application Development Approach and WorkingIRJET- MVC Framework: A Modern Web Application Development Approach and Working
IRJET- MVC Framework: A Modern Web Application Development Approach and Working
 
MVC Architecture: A Detailed Insight to the Modern Web Applications Developme...
MVC Architecture: A Detailed Insight to the Modern Web Applications Developme...MVC Architecture: A Detailed Insight to the Modern Web Applications Developme...
MVC Architecture: A Detailed Insight to the Modern Web Applications Developme...
 
MVVM Design Pattern NDC2009
MVVM Design Pattern NDC2009MVVM Design Pattern NDC2009
MVVM Design Pattern NDC2009
 
Pattern oriented architecture for web based architecture
Pattern oriented architecture for web based architecturePattern oriented architecture for web based architecture
Pattern oriented architecture for web based architecture
 

Code Camp 06 Model View Presenter Architecture

  • 1. Code Camp 06’ Presentation – Model View Presenter Design and Implementation Chase Thomas Consultant - MCSD.NET - Digineer Inc.
  • 2. Model View Presenter Architecture The Model View Presenter is a user interface architecture similar in nature to the model view controller. One of the greatest strengths in the MVP design is the ability to unit test user interface logic without a user interface. It’s origins are from the Taligent programming model for C++ and Java (based on the Smalltalk MVC) and has seen various implementations since it’s introduction. You can read more about the origins of MVP at the following URLs… ftp://www6.software.ibm.com/software/developer/library/mvp.pdf http://www.object-arts.com/papers/TwistingTheTriad.PDF
  • 3. Model View Presenter Architecture Traditionally The View has a dependency on the model. The view directly interacts with the Model and the controller directly interacts with the view – controlling complex UI logic and data mapping. Classic Model View Controller (MVC) Architecture.
  • 4.
  • 5.
  • 6.
  • 7. Model View Presenter Architecture Architecture UML (Class Diagram)
  • 8. Model View Presenter Architecture Architecture UML Diagram (Sequence – Loading an Employee Model)
  • 9. Model View Presenter Architecture Architecture UML Diagram (Sequence – Changing a value in the UI)
  • 10.
  • 11. Model View Presenter Architecture Implementation in C# (.NET 2.0) Building the model objects – Using Gestalt
  • 12. Model View Presenter Architecture Implementation in C# (.NET 2.0) Building the model objects – Using CSLA.NET
  • 13. Model View Presenter Architecture Implementation in C# (.NET 2.0) Building the model objects – Simple INotifyPropertyChanged Interface Implementation
  • 14.
  • 15. Model View Presenter Architecture Implementation in C# (.NET 2.0) Defining Our Interfaces – IEmployeeView Interface
  • 16.
  • 17. Model View Presenter Architecture Implementation in C# (.NET 2.0) Implementing our View Interface (part one – the Windows Form)… Implement the IEmployeeView interface on the windows form – the windows form implementation will receive information from the presenter and utilize it to perform display tasks.
  • 18. Model View Presenter Architecture Implementation in C# (.NET 2.0) Implementing our View Interface (part two – the UI Unit Tests)… Implement the IEmployeeView interface on the unit test class that has the TestFixture attribute applied. Within the unit test class you will need to create placeholder values for what the windows form user interface state (i.e. control colors – error messages – enabled / disabled state etc…). The unit test in essence becomes a Windows Form simulator. If you did it right – there will be nothing missed by using a Unit test in place of a windows form.
  • 19. Model View Presenter Architecture “ Blind Data binding” Problem: Since the view knows nothing about the model – how can we bind the view to our objects? Solution: Create a windows custom binding source object pass the binding source object to our presenter. Finally: Once the presenter has a reference to the windows forms Binding Source - establish the data bindings between the controls and the object in our form code.
  • 20. Model View Presenter Architecture Implementation of “Blind Data binding” in C# (.NET 2.0) Create and pass our binding source to the presenter
  • 21. Model View Presenter Architecture Implementation of “Blind Data binding” in C# (.NET 2.0) Establishing the Data bindings from our view The one of the cardinal rules of the MVP is that the View cannot know about or have a reference to the Model. That does not mean we can’t look at our Model property names and set up bindings in the form. We have not retained any knowledge of the Model within our presenter by doing this – just string values – you could even keep these values as constants in the presenter to centralize the information.
  • 22. Model View Presenter Architecture What is the Supervising Controller and Passive View? http://www.martinfowler.com/eaaDev/SupervisingPresenter.html The 10 second description of these two derivations of the MVP are that they vary in how much interaction the view has with the model. In a supervising presenter the model is exposed to the view in order to perform data binding or other simple data to UI mapping. http://www.martinfowler.com/eaaDev/PassiveScreen.html A passive view is closer to what we just discussed with the original MVP. The view has no dependence on the Model whatsoever. The presenter handles all data mapping between the UI and Model To describe these two “new” concepts is beyond the scope of this presentation – however since they are now the recommended approaches according to Fowler’s website, a brief explanation of the two are in order…
  • 23. Model View Presenter Architecture Sources of Material http://www.martinfowler.com/eaaDev/uiArchs.html http://www.martinfowler.com/eaaDev/SupervisingPresenter.html http://www.martinfowler.com/eaaDev/PassiveScreen.html http://msdn.microsoft.com/msdnmag/issues/06/08/DesignPatterns/

Hinweis der Redaktion

  1. Go to EmployeePresenter code example here since there is too much to display on the screen