40
Xamarin Forms, MVVM and Testing

GKAC 2015 Apr. - Xamarin forms, mvvm and testing

Embed Size (px)

Citation preview

Page 1: GKAC 2015 Apr. - Xamarin forms, mvvm and testing

Xamarin Forms, MVVM and Testing

Page 2: GKAC 2015 Apr. - Xamarin forms, mvvm and testing

Speaker

Page 3: GKAC 2015 Apr. - Xamarin forms, mvvm and testing
Page 4: GKAC 2015 Apr. - Xamarin forms, mvvm and testing
Page 5: GKAC 2015 Apr. - Xamarin forms, mvvm and testing

Basic(1989)

C(1991)

C++(1997)

Java(1997)C#(2005)

JavaScript(2008)

Others Languages

Page 6: GKAC 2015 Apr. - Xamarin forms, mvvm and testing

with Xamarin Forms

for 8 Months

iOS

with Xamarin Forms

for 3 Weeks

Android

Page 7: GKAC 2015 Apr. - Xamarin forms, mvvm and testing
Page 8: GKAC 2015 Apr. - Xamarin forms, mvvm and testing

Xamarin

Page 9: GKAC 2015 Apr. - Xamarin forms, mvvm and testing
Page 10: GKAC 2015 Apr. - Xamarin forms, mvvm and testing
Page 11: GKAC 2015 Apr. - Xamarin forms, mvvm and testing

C# 3.0 (2007)Java 8 (2014)

C# 5.0 (2013)

C# 4.0 (2010)

Lambda

Expression Trees

LINQ

Lambda

Streams

Dynamic

Asynchronous

Page 12: GKAC 2015 Apr. - Xamarin forms, mvvm and testing

Native

• Native User Interfaces

• Native API Access

• Native Performance

Page 13: GKAC 2015 Apr. - Xamarin forms, mvvm and testing
Page 14: GKAC 2015 Apr. - Xamarin forms, mvvm and testing
Page 15: GKAC 2015 Apr. - Xamarin forms, mvvm and testing

Xamarin Forms

Page 16: GKAC 2015 Apr. - Xamarin forms, mvvm and testing

App Logics

Cross-platform Natively Backed UI

Platform-specific API

iOS

Platform-specific API

Android

Platform-specific API

Windows Phone

Page 17: GKAC 2015 Apr. - Xamarin forms, mvvm and testing

XAML

• Extensible Application Markup Language

• XML

• WPF(2006)

• 2-way Binding

• Data Templating

Page 18: GKAC 2015 Apr. - Xamarin forms, mvvm and testing
Page 19: GKAC 2015 Apr. - Xamarin forms, mvvm and testing
Page 20: GKAC 2015 Apr. - Xamarin forms, mvvm and testing

Model View ViewModel

Page 21: GKAC 2015 Apr. - Xamarin forms, mvvm and testing

MVVM(Model-View-ViewModel)

• In 2005, John Gossman(Microsoft)

• A Variation of MVC

• Separation of Presentation and Presentation Logic

• 2-way Binding

• Testability

• WPF, Silverlight, Xamarin Forms, AngularJS, EmberJS, KnockoutJS, RoboBinding

• Introduction to Model/View/ViewModel pattern for building WPF apps

• WPF Apps With The Model-View-ViewModel Design Pattern

Page 22: GKAC 2015 Apr. - Xamarin forms, mvvm and testing

ViewModel

• An Abstraction of a View

• State and Behavior

• Does not need a reference to a view

Page 23: GKAC 2015 Apr. - Xamarin forms, mvvm and testing

ViewModel

Presentation Logic

View

User Interface

Model

Business Logic and

Data

2-way Binding

Page 24: GKAC 2015 Apr. - Xamarin forms, mvvm and testing

Unit Testing

Page 25: GKAC 2015 Apr. - Xamarin forms, mvvm and testing

Unit Testing

Pros

• Cheap

• Finds problems early

• Living Documentation

• As a Design Element

Cons

• Not catch integration errors

• Not catch system-level errors

• Can’t write for user interfaces

Page 26: GKAC 2015 Apr. - Xamarin forms, mvvm and testing

Presentation Layer

View(UI)

ViewModel(Presentation Logic)

• No Reference to Views

• No Lifecycle Constraint

Testable

Page 27: GKAC 2015 Apr. - Xamarin forms, mvvm and testing

Bindings

Page 28: GKAC 2015 Apr. - Xamarin forms, mvvm and testing

Bindings

• Properties

• Collections and Templating

• Commands

Page 29: GKAC 2015 Apr. - Xamarin forms, mvvm and testing

Properties

<Entry Text="{Binding NameEntry}" />

Page 30: GKAC 2015 Apr. - Xamarin forms, mvvm and testing

Collections and Templating

<ListView ItemsSource="{Binding Users}">

<ListView.ItemTemplate>

<DataTemplate>

<ViewCell>

<Label Text="{Binding Name}" />

</ViewCell>

</DataTemplate>

</ListView.ItemTemplate>

</ListView>

Page 31: GKAC 2015 Apr. - Xamarin forms, mvvm and testing

Commands

<Button Command="{Binding Add}" />

Page 32: GKAC 2015 Apr. - Xamarin forms, mvvm and testing

Events

Page 33: GKAC 2015 Apr. - Xamarin forms, mvvm and testing

Events

• PropertyChanged

• CollectionChanged

• CanExecuteChanged

Page 34: GKAC 2015 Apr. - Xamarin forms, mvvm and testing

Properties

• INotifyPropertyChanged

• PropertyChanged

Page 35: GKAC 2015 Apr. - Xamarin forms, mvvm and testing

Collection

• INotifyCollectionChanged

• CollectionChanged

Page 36: GKAC 2015 Apr. - Xamarin forms, mvvm and testing

Commands

• ICommand

• CanExecute

• CanExecuteChanged

Page 37: GKAC 2015 Apr. - Xamarin forms, mvvm and testing

Summary

Page 38: GKAC 2015 Apr. - Xamarin forms, mvvm and testing

Xamarin

• C#

• Native

• Visual Studio

• Designer

Page 39: GKAC 2015 Apr. - Xamarin forms, mvvm and testing

Xamarin Forms

• Cross-platform Natively Backed UI

• XAML

• 2-way Binding

• Data Templating

Page 40: GKAC 2015 Apr. - Xamarin forms, mvvm and testing

MVVM

• Separation of Presentation and Presentation Logic

• 2-way Binding

• Testability

• Property, Collection, Command

• PropertyChanged, CollectionChanged, CanExecuteChanged