+ All Categories
Home > Technology > Presentation Model

Presentation Model

Date post: 10-May-2015
Category:
Upload: alex-miranda
View: 258 times
Download: 0 times
Share this document with a friend
Popular Tags:
23
Presentation Model The First Contact
Transcript
Page 1: Presentation Model

Presentation ModelThe First Contact

Page 2: Presentation Model

Agenda

Quick Introduction Why should I care about it? View Model XAML Data Binding ViewModel Base Commands Validation Data Templates Resource Systems MVVM Framework How do I do…?

Page 3: Presentation Model

Quick Introduction: Presentation Patterns

Page 4: Presentation Model

UI Patterns Comparison

Passive View Supervising Controller Presentation Model

Page 5: Presentation Model

Presentation Model

“Probably the most annoying part of the Presentation Model is the synchronization between Presentation Model and view. It’s simple code to write, but I always like to minimize this kind of boring repetitive code.Ideally some kind of framework could handle this, which I’m hopping will happen some day with technologies like .NET’s data binding.”

Martin Fowler, 2004.

Page 6: Presentation Model

Model – View – ViewModel

Technology specific implementation of the PM Separation of Markup and Code Behaviour of the Application Look and Feel Tool Support

Page 7: Presentation Model

“Once a developer becomes comfortable with WPF and MVVM, it can be difficult to differentiate the two. ”. Josh Smith, MVVM Guru

Page 8: Presentation Model

Why should I care about it?

Order vs. Chaos Technology Choice Loose Coupling Testability (DEMO) Maintainable Code Blendability (DEMO) It is cool

Page 9: Presentation Model

<Disclaimer>

No Solution is Perfect Different Approaches

View-Centric ViewModel Centric

</Disclaimer>

Page 10: Presentation Model

View Model

Separation of Concerns Enables code reuse State + Operations Provides a Bindable Surface Not Dependent on the View Typically One-To-One ViewModel to View

One-To-Many is very common though

Page 11: Presentation Model

XAML

Humble View Plays nicely with Data Binding

capabilities

Page 12: Presentation Model

Data Binding

Binding Expression Binding Direction Binding to Elements Binding to Templates RelativeSource

Page 13: Presentation Model

DEMO

Page 14: Presentation Model

Commands

Delegate Command vs. Relay Command (DEMO) Uses WPF Behaviours capabilities Map Events to Commands (DEMO)

Page 15: Presentation Model

DEMO

Page 16: Presentation Model

Validation

Implemented on ViewModel, not in Model Class

Page 17: Presentation Model

DEMO

Page 18: Presentation Model

Messaging

Uses a light message bus to communicate between components Publish/Subscribe Frameworks (MVVM Light) (DEMO)

Page 19: Presentation Model

DEMO

MVVM Light Toolkit

Page 20: Presentation Model

ViewModel Locator

Repository of ViewModels Uses WPF DataTemplate Capabilities One View per ViewModel MVVM Light

Page 21: Presentation Model

DEMO

MVVM Light Toolkit

Page 22: Presentation Model

Trade-Offs

Agregate Model vs Proxy Property Start animation on the View through ViewModel How to close a window Clean and Shutdown Handle Navigation Add your own topic to be discussed…

Page 23: Presentation Model

And continues…

Not used only with WPF/Silverlight: ASP.NET MVC Knockout.js Java frameworks (RLY?)

To Far and Beyond… That’s it ;-)


Recommended