15
consulting training debugging wintellect.com Jeremy Likness Senior Consultant, Project Manager Twitter: @JeremyLikness Blog: http://csharperimage.jeremylikness. com/ Introduction to MVVM

Introduction to Model-View-ViewModel (MVVM)

Embed Size (px)

DESCRIPTION

A walkthrough of the fundamentals of Model-View-ViewModel (MVVM).

Citation preview

Page 1: Introduction to Model-View-ViewModel (MVVM)

consulting training debugging wintellect.com

Jeremy LiknessSenior Consultant, Project ManagerTwitter: @JeremyLiknessBlog: http://csharperimage.jeremylikness.com/

Introduction to MVVM

Page 2: Introduction to Model-View-ViewModel (MVVM)

wintellect.comconsulting training debugging

consulting training debugging

Founded by top experts on Microsoft – Jeffrey Richter, Jeff Prosise, and John Robbins – we pull out all the stops to help our customers achieve their goals through advanced software-based consulting and training solutions.

Consulting & Debugging• Architecture, analysis, and design services• Full lifecycle custom software development• Content creation• Project management• Debugging & performance tuning

Training• On-site instructor-led training• Virtual instructor-led training• Devscovery conferences

what we do

who we are

how we do it

Page 3: Introduction to Model-View-ViewModel (MVVM)

wintellect.comconsulting training debugging

Agenda

• What is MVVM?• Why use MVVM?• MVVM Frameworks Overview• What is the Cost?• Demo• MVVM Prescription• Questions

• What is MVVM?• Why use MVVM?• MVVM Frameworks Overview• What is the Cost?• Demo• MVVM Prescription• Questions

Page 4: Introduction to Model-View-ViewModel (MVVM)

wintellect.comconsulting training debugging

What is MVVM?

Page 5: Introduction to Model-View-ViewModel (MVVM)

wintellect.comconsulting training debugging

What is MVVM?

• Do you ever have to start work on an application before the design team is ready?

• Do you make updates in parallel with the design team?

• Do you unit test your solutions?• Do you reuse code and components both within

and across projects?• Do you ever have to change the user interface, and

wouldn’t it be nice to do it without having to hit your code as well?

• MVVM solves these types of problems!

• Do you ever have to start work on an application before the design team is ready?

• Do you make updates in parallel with the design team?

• Do you unit test your solutions?• Do you reuse code and components both within

and across projects?• Do you ever have to change the user interface, and

wouldn’t it be nice to do it without having to hit your code as well?

• MVVM solves these types of problems!

Page 6: Introduction to Model-View-ViewModel (MVVM)

wintellect.comconsulting training debugging

What is MVVM? The Model

• Domain object• Data/Information and/or Behavior• Possible persistence information (id, GUID, etc)• Separate from “how it got there”

• Domain object• Data/Information and/or Behavior• Possible persistence information (id, GUID, etc)• Separate from “how it got there”

Page 7: Introduction to Model-View-ViewModel (MVVM)

wintellect.comconsulting training debugging

What is MVVM? The View

• What the user “sees” / experiences• User-friendly format for presentation• Multiple inputs (gestures)• Behaviors• Events• Data-bindings

• What the user “sees” / experiences• User-friendly format for presentation• Multiple inputs (gestures)• Behaviors• Events• Data-bindings

Page 8: Introduction to Model-View-ViewModel (MVVM)

wintellect.comconsulting training debugging

What is MVVM? The View Model• The “controller”• Doesn’t know about the view • Exposes methods and commands• Coordinates with services• “Owns” models, and knows how to retrieve/update

them• Might be used in multiple views• Can communicate with other view models

• The “controller”• Doesn’t know about the view • Exposes methods and commands• Coordinates with services• “Owns” models, and knows how to retrieve/update

them• Might be used in multiple views• Can communicate with other view models

Page 9: Introduction to Model-View-ViewModel (MVVM)

wintellect.comconsulting training debugging

What is MVVM? The View Model

Page 10: Introduction to Model-View-ViewModel (MVVM)

wintellect.comconsulting training debugging

10 Reasons to Use MVVM

1. Separation of concerns/de-coupling.

2. Designer/developer workflow.

3. Unit testing.

4. Data-binding.

5. Code reuse.

6. Modularity.

7. Refactoring containment.

8. Extensibility.

9. Tools support (Windows Phone 7, MVVM Light, etc.)

10.Pattern vocabulary.

1. Separation of concerns/de-coupling.

2. Designer/developer workflow.

3. Unit testing.

4. Data-binding.

5. Code reuse.

6. Modularity.

7. Refactoring containment.

8. Extensibility.

9. Tools support (Windows Phone 7, MVVM Light, etc.)

10.Pattern vocabulary.

Page 11: Introduction to Model-View-ViewModel (MVVM)

wintellect.comconsulting training debugging

MVVM Frameworks

1. PRISM (Guidance/Quickstart).

2. MVVM Light.

3. Caliburn.

4. Cinch.

5. nRoute.

1. PRISM (Guidance/Quickstart).

2. MVVM Light.

3. Caliburn.

4. Cinch.

5. nRoute.

Page 12: Introduction to Model-View-ViewModel (MVVM)

wintellect.comconsulting training debugging

How Much Does it Cost?

• Learning Curve (Developers)• Bigger down payment (architecture, infrastructure)

- Low interest rates and minimum monthly payments!

• Visibility (de-coupling can backfire)• Duplication of code (e.g. WCF RIA)

• Learning Curve (Developers)• Bigger down payment (architecture, infrastructure)

- Low interest rates and minimum monthly payments!

• Visibility (de-coupling can backfire)• Duplication of code (e.g. WCF RIA)

Page 13: Introduction to Model-View-ViewModel (MVVM)

wintellect.com

demo

consulting training debugging

MVVM “Before and After”

Page 14: Introduction to Model-View-ViewModel (MVVM)

wintellect.comconsulting training debugging

MVVM Framework Prescription

1. View management.

2. View and view-model routing.

3. INotifyPropertyChanged.

4. IDataErrorInfo.

5. ICommand (UObey)

6. Dialogs.

7. Messaging.

8. Navigation.

9. Services.

10.Unit testing.

1. View management.

2. View and view-model routing.

3. INotifyPropertyChanged.

4. IDataErrorInfo.

5. ICommand (UObey)

6. Dialogs.

7. Messaging.

8. Navigation.

9. Services.

10.Unit testing.

Page 15: Introduction to Model-View-ViewModel (MVVM)

consulting training debugging wintellect.com

Questions?

Jeremy LiknessSenior Consultant, Project ManagerTwitter: @JeremyLiknessBlog: http://csharperimage.jeremylikness.com/