laurent bugnion senior user experience integrator identitymine http://[www|blog].galasoft.ch

22

Post on 19-Dec-2015

224 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Laurent Bugnion Senior User Experience Integrator IdentityMine http://[www|blog].galasoft.ch
Page 2: Laurent Bugnion Senior User Experience Integrator IdentityMine http://[www|blog].galasoft.ch

Laurent BugnionSenior User Experience IntegratorIdentityMinehttp://[www|blog].galasoft.chhttp://www.identitymine.com

Understanding the MVVM pattern

Page 3: Laurent Bugnion Senior User Experience Integrator IdentityMine http://[www|blog].galasoft.ch

What is MVVM?

A weird acronymModel – View – ViewModel« MVVM in a SLOOB with SLUT »

Woven into WPF/SLSome confusion:

MVVM is really just the patternThe rest are helpers, practices, etc

Page 4: Laurent Bugnion Senior User Experience Integrator IdentityMine http://[www|blog].galasoft.ch

The MVC pattern

Model View

Controller

Page 5: Laurent Bugnion Senior User Experience Integrator IdentityMine http://[www|blog].galasoft.ch

The Passive View pattern

Model View

Controller

Page 6: Laurent Bugnion Senior User Experience Integrator IdentityMine http://[www|blog].galasoft.ch

The Presentation Model pattern

Model View

Presentation Model

(ViewModel)

DataBinding

Page 7: Laurent Bugnion Senior User Experience Integrator IdentityMine http://[www|blog].galasoft.ch

Blendability

Testability, Maintainability, Blendability

“The ability to be edited in Blend”

(and Visual Studio designer…)

Differentiate code in design and runtime

Create design time data

Page 8: Laurent Bugnion Senior User Experience Integrator IdentityMine http://[www|blog].galasoft.ch

Demo

Hello MVVM (and Hi Blend)

Page 9: Laurent Bugnion Senior User Experience Integrator IdentityMine http://[www|blog].galasoft.ch

Bridging the gap

View

ViewModel

DataBinding Commands Messages

Model

Page 10: Laurent Bugnion Senior User Experience Integrator IdentityMine http://[www|blog].galasoft.ch

Bridging the gap

View

ViewModelView

ViewModel

View

ViewModelMessages

Messages+ callback

Page 11: Laurent Bugnion Senior User Experience Integrator IdentityMine http://[www|blog].galasoft.ch

Commands

“Point of entry” for a methodCan be data boundICommand interface

Execute methodCanExecute methodCanExecuteChanged event

Page 12: Laurent Bugnion Senior User Experience Integrator IdentityMine http://[www|blog].galasoft.ch

Messaging

Should be simple by defaultPossible to open filtered channels

To a target Type (or an Interface)With a Token

No constraints at all

Page 13: Laurent Bugnion Senior User Experience Integrator IdentityMine http://[www|blog].galasoft.ch

Demo

Commands and RelayCommands,Messaging

Page 14: Laurent Bugnion Senior User Experience Integrator IdentityMine http://[www|blog].galasoft.ch

MVVM Light Toolkit

“Breaking the monotony”http://www.galasoft.ch/mvvm/getstartedhttp://mvvmlight.codeplex.comV3 SP1 released with phone supportKeep it smallKeep it simple

Page 15: Laurent Bugnion Senior User Experience Integrator IdentityMine http://[www|blog].galasoft.ch

MVVM Light Toolkit

ESSENTIALSRelayCommandMessengerViewModelBase

EXTRASEventToCommandDispatcherHelper

Page 16: Laurent Bugnion Senior User Experience Integrator IdentityMine http://[www|blog].galasoft.ch

MVVM Light Toolkit

Project templates (VS + Blend)Item templates (VS + Blend)Code snippets

Page 17: Laurent Bugnion Senior User Experience Integrator IdentityMine http://[www|blog].galasoft.ch

Demo

MVVM Light, Unity, Blendability

Page 18: Laurent Bugnion Senior User Experience Integrator IdentityMine http://[www|blog].galasoft.ch

Flaws of MVVM

Too much code neededINotifyPropertyChangedCommands

Some operations are tricky (set focus…)Not applicable to ASP.NET, etcMessage to community is not clear

Page 19: Laurent Bugnion Senior User Experience Integrator IdentityMine http://[www|blog].galasoft.ch

Debunk the myths

“No code in the code behind”“If you put code in the View's code-behind, the MVVM police will take your family away”“No need for converters”

“MVVM is only suitable for big projects”“MVVM costs performance”“MVVM is complex / makes my head hurt”

Page 20: Laurent Bugnion Senior User Experience Integrator IdentityMine http://[www|blog].galasoft.ch

Debunk the myths

“I don’t need separation because I don’t have a designer”“You cannot use MVVM with other patterns”“MVVM will make you rich and attractive”

Page 21: Laurent Bugnion Senior User Experience Integrator IdentityMine http://[www|blog].galasoft.ch

Further informationhttp://blog.galasoft.ch

http://www.galasoft.ch/mvvm/getstarted

http://tinyurl.com/mvvmexplained

Twitter: @LBugnion

Page 22: Laurent Bugnion Senior User Experience Integrator IdentityMine http://[www|blog].galasoft.ch