Why prism for xamarin.forms

Post on 16-Apr-2017

617 Views

Category:

Engineering

3 Downloads

Preview:

Click to see full reader

Transcript

© 2016 @nuits_jp

WhyPrism for Xamarin.Forms

2016.10.28 JXUGC #18

© 2016 @nuits_jp 2

中村 充志 / Atsushi Nakamura• Enterprise 系アプリケーションアーキテクト• Prism for WPF を仕事にて活用• Xamarin を仕事にしたくて奮闘中

• Twitter : @nuits_jp• Blog : http://www.nuits.jp• Company : RICOH JAPAN Corp.

自己紹介

© 2016 @nuits_jp

次のふたつを理解していただくこと• なぜ Prism を使うべきか?• だれが Prism を使うべきか?

3

Today’s Goal

© 2016 @nuits_jp 4

• Introduction• What is Prism? & What do you get?• Why Prism for Xamarin.Forms?• DEMO

Agenda

© 2016 @nuits_jp

Agenda

• Introduction• What is Prism? & What do you get?• Why Prism for Xamarin.Forms?• DEMO

5

© 2016 @nuits_jp

• Xamarin.Forms をつかう→ MVVM パターンにしよう→ 素のままだとつらい!

Introduction

© 2016 @nuits_jp 7

MVVM Pattern で、辛くなりやすいところ

View ViewModel Model

Binding &Command Update

Notification

Notification

• 画面遷移• 確認ダイアログ• 選択ダイアログ

© 2016 @nuits_jp

• Xamarin.Forms をつかう→ MVVM パターンにしよう→ 素のままだとつらい!→ MVVM 支援ライブラリつかいたい!

Prism or MVVM Light Toolkit ?

何つかおう?

© 2016 @nuits_jp 9

Who is He?

© 2016 @nuits_jp 10

God has told us

© 2016 @nuits_jp

完11

© 2016 @nuits_jp 12

Prism or MVVM Light Toolkit

Prism凄いんだろうけどむず

かしそう

MVVM Light Toolkit

シンプルで分かりやすくて取り組みやすそう

© 2016 @nuits_jp

Agenda

• Introduction• What is Prism? & What do you get?• Why Prism for Xamarin.Forms?• DEMO

13

© 2016 @nuits_jp 14

• XAML Application Framework• Guidance• Patterns & Practices• Testable & Maintainable• Open Source• .NET Foundation

What is Prism?

© 2016 @nuits_jp 15

• MVVM Support• Commanding• Messaging• Navigation• Page Dialog Service• Dependency Injection• Logging

What do you get?

© 2016 @nuits_jp

Agenda

• Introduction• What is Prism? & What do you get?• Why Prism for Xamarin.Forms?• DEMO

16

© 2016 @nuits_jp 17

Prism & MVVM Light Toolkit

© 2016 @nuits_jp 18

Prism & MVVM Light Toolkit

© 2016 @nuits_jp

• MVVM Support• Commanding• Messaging• Navigation• Page Dialog Service• Dependency Injection• Logging

19

What do you get?

© 2016 @nuits_jp

• XAML Application Framework• Guidance• Patterns & Practices• Testable & Maintainable• Open Source• .NET Foundation

20

What is Prism?

© 2016 @nuits_jp 21

よく見かける MVVM の図

View ViewModel Model

Binding &Command Update

Notification

Notification

プレゼンテーション

その他

© 2016 @nuits_jp 22

実際の割合

View

ViewMode

l Model

Binding &Command Update

Notification

Notification

プレゼンテーション

その他

© 2016 @nuits_jp 23

View が厚くて凄い例①

@masatoru 氏作SkiaSharp で自力で縦組 View

© 2016 @nuits_jp 24

View が厚くて凄い例②

@omanuke 氏作SkiaSharp で自力描画している株式チャート

© 2016 @nuits_jp 25

実際の割合

View

ViewMode

l Model

Binding &Command Update

Notification

Notification

プレゼンテーション

その他

© 2016 @nuits_jp

Model にも• 専門性の高い領域• テストが難しい領域が多数存在します

モバイル&クロスプラットフォーム開発

© 2016 @nuits_jp

• プラットフォーム依存領域• 時間• 非同期処理• プッシュ通知• センサー類(位置情報、加速度、カメラ)

モバイルクロスプラットフォームは課題の山

© 2016 @nuits_jp

• Prism は MVVM の課題だけでなく、これらの課題に対しても、ガイダンスを提供します

• Prism はアプリケーションを開発する上での、パターンとプラクティスの集合です

• そしてこれらは、テスト容易性と保守容易性を提供します

Why Prism for Xamarin.Forms

© 2016 @nuits_jp

「 MVVM 初めてやるけど、 Prism って難しそう」という人ほど、使うべきです。

だれが Prism を使うべきか?

© 2016 @nuits_jp

#DEMO

30

© 2016 @nuits_jp

• 素の Xamarin.Forms のみで作ったアプリを Prism を適用してリファクタリングします• TDD ( Test First )でいきます• Test では Moq を利用します• ReSharper 先生最高!

デモ概要

© 2016 @nuits_jp 32

デモアプリクラス構成class Class Model

Xamarin.Forms

ModelViewModelView

UWP

Android

iOSPCL

MainPage MainPageViewModel

TextSpeachPage TextSpeachPageViewModel

«interface»ITextSpeachService

TextSpeachService

TextSpeachService

TextSpeachServiceDependencyServiceNavigationPage

«instantiate»

«instantiate»«use»

«use»

«instantiate»

© 2016 @nuits_jp

#DEMO

33

© 2016 @nuits_jp

https://github.com/nuitsjp/WhyPrismSession

このあとすぐ資料を Twitter に案内します。dots のイベントページへの紐づけもしますので、何れかからご覧ください。

デモコードのリポジトリ

© 2016 @nuits_jp

いい入門サイトをたまたま知ってます!

【 Xamarin 】 Prism.Forms 入門http://www.nuits.jp/entry/2016/08/22/173858

Xamarin 関わらず多数の日本語の Prism 情報があります

Prism 自習用リポジトリhttps://github.com/runceel/PrismEdu

35

まとめ

© 2016 @nuits_jp

#Xamarin はいいぞ

36

© 2016 @nuits_jp

#Prism もいいぞ

37

top related