19
www.bestppt.com Playtime is over building real- world apps with Xamarin.Forms 28 January 2017

Session dotNed Saturday 28 januari 2017

Embed Size (px)

Citation preview

Page 1: Session dotNed Saturday 28 januari 2017

www.bestppt.com

Playtime is over building real-world apps with Xamarin.Forms

28 January 2017

Page 2: Session dotNed Saturday 28 januari 2017

Who is that handsome gentleman anyways?

2

Gerald Versluis@jfversluis

blog.verslu.is

[email protected]

Page 3: Session dotNed Saturday 28 januari 2017

Feel free to ask

3

Gerald Versluis@jfversluis

blog.verslu.is

[email protected]

Page 4: Session dotNed Saturday 28 januari 2017

What I have for you today…

4

1 What does it look like? What does it do?The end result

2 What is the structure behind it? What concepts are used?

Architecture

3 What you are here for anyway, demo time!Code

4 Not to miss NuGets for developing with Xamarin

There’s a NuGet for that…

5 Summary, thank you, high fives all aroundIt’s a wrap

Page 5: Session dotNed Saturday 28 januari 2017

The end result

5

BudgetGaming

budgetgaming.nl

• Available in the App Store • Built with Xamarin.Forms • ~1000 users per month

Page 6: Session dotNed Saturday 28 januari 2017

www.bestppt.com

Architecture Great! But what does it look like in diagrams?

Page 7: Session dotNed Saturday 28 januari 2017

7

MVVM

• Model–view–viewmodel • Architectural pattern • Inspired by MVC • Databinding &

Commanding • Uses XAML as binder

Architecture - continued

Page 8: Session dotNed Saturday 28 januari 2017

8

Why MVVM?

ViewView markup code

WinForms, XAML, CSHTML, etc.

Code-behind

Model

• Hard to test • UI and logic is tightly

coupled

Architecture - continued

Page 9: Session dotNed Saturday 28 januari 2017

9

That’s why MVVM!

ViewView markup code

WinForms, XAML, CSHTML, etc.

Code-behind

ModelViewModel

Databinding

& Commands

PropertyChanged

Easy to combine with Dependency Injection

Architecture - continued

Page 10: Session dotNed Saturday 28 januari 2017

10

Databinding

• Crucial for MVVM • Normal class, normal properties • Assign to DataContext property • Implement INotifyChanged • One-way or two-way

Architecture - continued

Page 11: Session dotNed Saturday 28 januari 2017

11

Commands

• Instead of Events • Executes logic • Bindable • Implements ICommand

• Execute • CanExecute • CanExecuteChanged

Architecture - continued

Page 12: Session dotNed Saturday 28 januari 2017

12

FreshMvvm

• Very light-weight • Built with Xamarin.Forms in mind • PageModel to PageModel navigation • Built-in IoC • Open-source (github.com/rid00z/FreshMvvm) • MvvmCross, Prism, Light Mvvm …

Architecture - continued

Page 13: Session dotNed Saturday 28 januari 2017

13

BudgetGaming Website/API

BudgetGaming App

UI iOS

UI Xamarin.Forms

UI Android

ViewModels

Service(s)

Models

Shared code

Architecture - continued

Page 14: Session dotNed Saturday 28 januari 2017

14

Shared code

Portable Class Library Shared Project .NET Standard

Architecture - continued

Page 15: Session dotNed Saturday 28 januari 2017

www.bestppt.com

There’s a NuGet for that… With these NuGets your life will be a lot easier

Page 16: Session dotNed Saturday 28 januari 2017

NuGet packages to make all of our lives easier!

16

Xamarin.Plugins.Settings Simple type (user) settings

Xamarin.Plugins.Connectivity Network connectivity

ACR.UserDialogs Alerts, loading, ActionSheets

FreshMvvm Lightweight, easy to use MVVM framework

PropertyChanged.Fody INotifyPropertyChanged made easy

FFImageLoading Image caching, effects, etc.

Polly Fluent exception handling

Refit Type-safe REST library

Note: install on both PCL and platform project

Page 17: Session dotNed Saturday 28 januari 2017

www.bestppt.com

It’s a wrap Just one more slide

Page 18: Session dotNed Saturday 28 januari 2017

18

• MVVM is awesome • Better testability • Better maintainability • Clean architecture allows better

code sharing

In short…

Page 19: Session dotNed Saturday 28 januari 2017

#shamelessselfpromotion

19

Gerald Versluis@jfversluis

blog.verslu.is

github.com/jfversluis