20
Understanding MVVM Design Pattern Silverlight adventures of asp.net developer Ljubomir Zivanovic senior software developer, netcetera

Ljubomir zivanovic understandingmvvm-designpattern (1)

Embed Size (px)

Citation preview

Page 1: Ljubomir zivanovic understandingmvvm-designpattern (1)

Understanding MVVM Design PatternSilverlight adventures of asp.net developer

Ljubomir Zivanovicsenior software developer, netcetera

Page 3: Ljubomir zivanovic understandingmvvm-designpattern (1)

Background

Page 4: Ljubomir zivanovic understandingmvvm-designpattern (1)

Motivation

Huge number of new technologies & tools

[Almost] Daily announcements of new stuff

WPF, WCF, WF, Silverlight, .NET 4.0, LINQ, DLR, TPL

ASP.NET MVC, jQuery, SharePoint, VSTO, Odata, EF

Azure, Surface, XNA, Windows 7, WP7, MEF, F#

Page 5: Ljubomir zivanovic understandingmvvm-designpattern (1)

Motivation

impressions

WP7 & Silverlight = dream team!

MVVMSilverlight

WP7HTML5

Page 6: Ljubomir zivanovic understandingmvvm-designpattern (1)

Situation

Q: How to jump to SL/WP7 Bandwagon in a most efficient way?

A: Hands on - Download WP7 SDK and start playing

Page 7: Ljubomir zivanovic understandingmvvm-designpattern (1)

Getting started

My First WP7 Silverlight project

DEMO

Page 8: Ljubomir zivanovic understandingmvvm-designpattern (1)

Demo feedback

Similarities with ASP.NET:

Identical code behind architecture

XAML [is similar to] HTML markup

XAML [looks like] C# object initialization notation

Well known environment

Page 9: Ljubomir zivanovic understandingmvvm-designpattern (1)

Leveraging Lessons Learned

Same architectural patterns apply to this environment as well.

RAD development practices are OK for one-hour projects

For something even slightly complicated we need better

architecture – here comes MVVM…

Page 10: Ljubomir zivanovic understandingmvvm-designpattern (1)

Meet MVVM

Model View ViewModel

Why use it?

What it solves?

Benefits?

View

View Model

Model

Page 11: Ljubomir zivanovic understandingmvvm-designpattern (1)

The Star - ViewModel

View ModelCode

Model(Domain, SQL, File,

Memory...)

View(XAML)

User Interface (pages, controls)

Services

Page 12: Ljubomir zivanovic understandingmvvm-designpattern (1)

Getting started with MVVM

My Second WP7 Silverlight project

DEMO

Page 13: Ljubomir zivanovic understandingmvvm-designpattern (1)

What’s in it for me?

Maintainability

Testability

Blendability

Separation of concerns

Page 14: Ljubomir zivanovic understandingmvvm-designpattern (1)

Why is ViewModel pushed

There is a huge shift in paradigm involved:

meet

Developers are not the only ones responsible for their applications!

Page 15: Ljubomir zivanovic understandingmvvm-designpattern (1)

How is ViewModel supported

Vast amount of available tools & frameworks that support MVVM:

Prism, MVVM Light, Caliburn, …..

They helps a lot and speedup your development process and adding benefits at the same time

Page 16: Ljubomir zivanovic understandingmvvm-designpattern (1)

Reverse analogy…

IF Silverlight [has similar architecture to] ASP.NET

AND Silverlight [benefits from] MVVM

THEN ASP.NET [can benefit from ?] MVVM

Result: http://aspnetmvvm.codeplex.com/

Page 17: Ljubomir zivanovic understandingmvvm-designpattern (1)

MVVM on other platforms

Page 18: Ljubomir zivanovic understandingmvvm-designpattern (1)
Page 19: Ljubomir zivanovic understandingmvvm-designpattern (1)

Q&A Session

• Complete an evaluation form and enter to win!– Telerik Ultimate

Collections

– Pluralsight yearly subscriptions

– JetBrains Tools

– RedGate .NET Profiler Pro or other tools

– O’Raily books

– Component One Suites

– CodeSmith Tools

– and many more…

Page 20: Ljubomir zivanovic understandingmvvm-designpattern (1)

06th November, FON University