three's company - writing for the desktop, browser, and phone

38
Tips & Tricks for Targeting Multiple Platforms with Portable Code Presented by Sarah Dutkiewicz, Cleveland Tech Consulting [email protected]

Upload: sarah-dutkiewicz

Post on 19-May-2015

227 views

Category:

Technology


2 download

DESCRIPTION

Presented to Akron AITP on 5/21/2013

TRANSCRIPT

Page 1: Three's Company - Writing for the Desktop, Browser, and Phone

Tips & Tricks for Targeting Multiple Platforms with Portable Code

Presented by Sarah Dutkiewicz, Cleveland Tech Consulting

[email protected]

Page 2: Three's Company - Writing for the Desktop, Browser, and Phone
Page 3: Three's Company - Writing for the Desktop, Browser, and Phone

Scenarios

Tips & tricks for general multiple platform development

Overview of Portable Class Library in .NET

Page 5: Three's Company - Writing for the Desktop, Browser, and Phone

Formerly known as a Windows Live ID

Combination of email address and password

Unified login for Microsoft tools and other apps that ask for a Microsoft account

Xbox LIVE

Outlook.com

SkyDrive

Windows Phone

Skype

Page 6: Three's Company - Writing for the Desktop, Browser, and Phone
Page 7: Three's Company - Writing for the Desktop, Browser, and Phone

Data storage in the cloud

Office in the browser – including Word, Excel, PowerPoint, and OneNote

Supported platforms include: Windows 8 (built-in)

Windows Vista and later

Mac OS X

Mobile

Windows Phone

iPhone / iPad

Android

Page 9: Three's Company - Writing for the Desktop, Browser, and Phone
Page 10: Three's Company - Writing for the Desktop, Browser, and Phone

How to Develop For Multiple Devices/Platforms

Page 11: Three's Company - Writing for the Desktop, Browser, and Phone

The better understanding of your audience, the better understanding of which platforms to target.

The better understanding of which platforms to target, the better view of what features are available as an overall view and platform-specific

Page 12: Three's Company - Writing for the Desktop, Browser, and Phone
Page 13: Three's Company - Writing for the Desktop, Browser, and Phone

Be sure you understand what it is you are building and what platform(s) you are targeting.

Write the code once and reuse it, rather than writing the code in multiple places and then realizing it can be isolated into one library.

Page 14: Three's Company - Writing for the Desktop, Browser, and Phone
Page 15: Three's Company - Writing for the Desktop, Browser, and Phone

Media – images, video

Design aspects

Models

View Models

Consumed APIs/RESTful services

Page 16: Three's Company - Writing for the Desktop, Browser, and Phone

Web & Windows Phone – Perhaps HTML5, Silverlight, or C#

Web, Windows Phone, and Windows Store – C#

Web & general mobile – consider HTML5

Page 17: Three's Company - Writing for the Desktop, Browser, and Phone
Page 18: Three's Company - Writing for the Desktop, Browser, and Phone

User Interface

Business Logic

Data Layer

Page 19: Three's Company - Writing for the Desktop, Browser, and Phone

Some code is shareable without the portable class library

Share the code that would be the same on each platform

Typically not the UI

Mostly as much business logic as possible

Perhaps data layer

Portable view models

Validation

Use design patterns that lend themselves to reusability

Model-View-ViewModel (MVVM)

Model-View-Controller (MVC)

Use third party tools that support cross-platform development

Page 20: Three's Company - Writing for the Desktop, Browser, and Phone

Appcelerator

PhoneGap

RhoMobile

WidgetPad

MoSync

Page 21: Three's Company - Writing for the Desktop, Browser, and Phone

Visual Studio for targeting Windows

MonoGame to help target many platforms:

iOS

Android

Mac OS X

Linux

Windows 8 Metro

Futures include:

Windows Phone 8

OUYA (Android-based gaming station)

PlayStation Mobile

Page 22: Three's Company - Writing for the Desktop, Browser, and Phone

A look at Portable Class Libraries

Page 23: Three's Company - Writing for the Desktop, Browser, and Phone

Desktop

Web

Phone

Cloud

Xbox

Tablets

Page 24: Three's Company - Writing for the Desktop, Browser, and Phone

.NET 4 and Silverlight 4

Portable Library Tools for Visual Studio 2010

Built-in Portable Library support in Visual Studio 2012

Page 25: Three's Company - Writing for the Desktop, Browser, and Phone

.NET Framework 4, Update 4.0.3 for the .NET Framework 4, and .NET Framework 4.5

.NET for Windows store apps

Windows Phone 7 and higher (Windows Phone SDK 8.0 for Windows Phone 8 support)

Silverlight 4 and 5

Xbox 360

Page 26: Three's Company - Writing for the Desktop, Browser, and Phone
Page 27: Three's Company - Writing for the Desktop, Browser, and Phone

They must be shared across the target platforms you selected.

They must behave similarly across those platforms.

They must not be candidates for deprecation.

They must make sense in a portable environment, especially when supporting members are not portable.

Portable Class Library support appears under Version Information for a MSDN article

Page 28: Three's Company - Writing for the Desktop, Browser, and Phone

Include shared business logic and data layer logic in the portable class libraries

Use MVVM to write the apps

Models and View Models can be shared across platforms and included in portable libraries

Platform-specific views

Portable abstractions for non-portable functionality

Implement the abstractions for each platform

Use IoC or service locator to hook up implementations

Page 29: Three's Company - Writing for the Desktop, Browser, and Phone

• How to display information

• Written in XAML, HTML, some other markup language

• Platform-specificView

• What information to display

• Flow of interaction

• Can be shared in a portable class libraryView Model

• Data objects

• Business logic

• Can be shared in a portable class libraryModel

Page 30: Three's Company - Writing for the Desktop, Browser, and Phone

Portable Class Library

(Models & View Models)

Windows Store App

(Views)

Windows Phone App

(Views)

Silverlight (Views)

Page 31: Three's Company - Writing for the Desktop, Browser, and Phone
Page 32: Three's Company - Writing for the Desktop, Browser, and Phone

Calling Non-Portable Members from a Portable Class

Cannot call the non-portables directly

Need to create an abstract class in the Portable Class Library project and use that class from all portable code

Page 33: Three's Company - Writing for the Desktop, Browser, and Phone

HelpDesk Application

Metro Style App

Windows Phone 7 App

Download Source Code

Page 34: Three's Company - Writing for the Desktop, Browser, and Phone

Store common logic in the portable class library

Business logic, but not UI

Use abstract classes to work with non-portable code

For example, this may be applied to the data layer.

Use the MVVM pattern to help minimize code.

Page 36: Three's Company - Writing for the Desktop, Browser, and Phone

Write Portable Code

Visual Studio Toolbox: Portable Class Libraries

Portable Class Libraries Contrib

Build 2012: Create Cross-platform Apps using Portable Class Libraries

.NET 4.5: David Kean and Mircea Trofin – Portable Libraries

Coding4Fun: Portable is as portable does… Maximizing code reuse via the magic of the Portable Class Library

Coding4Fun: Digging into your code with the free Microsoft Code Digger and the power of Pex

CodeProject: MonoGame Goes Portable

How to Make Portable Class Libraries Work for You

Example: Disentanglement by Daniel Plaisted

Page 37: Three's Company - Writing for the Desktop, Browser, and Phone
Page 38: Three's Company - Writing for the Desktop, Browser, and Phone

Portable Class Libraries and other portable libraries make it easy to develop for multiple platforms.

Know the lay of the land.

Know your audience.

Know your goals for your app.

Keep your commonalities together.

Develop accordingly.