itcamp 2013 - lorant domokos - chasing the one codebase, multiple platforms dream

52
itcampro @ itcamp13 # Premium conference on Microsoft technologies Chasing the one codebase, multiple platforms dream Lorant Domokos Fortech Microsoft Student Partners

Upload: itcamp

Post on 08-May-2015

606 views

Category:

Technology


2 download

TRANSCRIPT

Page 1: ITCamp 2013 - Lorant Domokos - Chasing the one codebase, multiple platforms dream

itcampro@ itcamp13# Premium conference on Microsoft technologies

Chasing the one codebase, multiple platforms dream

Lorant Domokos

Fortech

Microsoft Student Partners

Page 2: ITCamp 2013 - Lorant Domokos - Chasing the one codebase, multiple platforms dream

itcampro@ itcamp13# Premium conference on Microsoft technologies

Development &

MobileHuge thanks to our sponsors!

Page 3: ITCamp 2013 - Lorant Domokos - Chasing the one codebase, multiple platforms dream

itcampro@ itcamp13# Premium conference on Microsoft technologies

Development &

Mobile

• Why HTML5?

• PhoneGap

• Best practices

• Knockout, Durandal

• Breeze

• TypeScript

• Tooling

Agenda

Page 4: ITCamp 2013 - Lorant Domokos - Chasing the one codebase, multiple platforms dream

itcampro@ itcamp13# Premium conference on Microsoft technologies

Development &

Mobile

• Convince you that HTML5 is a valid

alternative in some scenarios

• HTML5 is rich enough

• JavaScript is maturing

• Lots of great frameworks

• Great community

• The tooling is improving

• …probably the future

Objective

Page 5: ITCamp 2013 - Lorant Domokos - Chasing the one codebase, multiple platforms dream

itcampro@ itcamp13# Premium conference on Microsoft technologies

Development &

Mobile

• The Helios story

Background

Page 6: ITCamp 2013 - Lorant Domokos - Chasing the one codebase, multiple platforms dream

itcampro@ itcamp13# Premium conference on Microsoft technologies

WHY HTML5?

Page 7: ITCamp 2013 - Lorant Domokos - Chasing the one codebase, multiple platforms dream

itcampro@ itcamp13# Premium conference on Microsoft technologies

Development &

Mobile

Page 8: ITCamp 2013 - Lorant Domokos - Chasing the one codebase, multiple platforms dream

itcampro@ itcamp13# Premium conference on Microsoft technologies

Development &

Mobile

Page 9: ITCamp 2013 - Lorant Domokos - Chasing the one codebase, multiple platforms dream

itcampro@ itcamp13# Premium conference on Microsoft technologies

Development &

Mobile

Page 10: ITCamp 2013 - Lorant Domokos - Chasing the one codebase, multiple platforms dream

itcampro@ itcamp13# Premium conference on Microsoft technologies

Development &

Mobile

Page 11: ITCamp 2013 - Lorant Domokos - Chasing the one codebase, multiple platforms dream

itcampro@ itcamp13# Premium conference on Microsoft technologies

Development &

Mobile

Page 12: ITCamp 2013 - Lorant Domokos - Chasing the one codebase, multiple platforms dream

itcampro@ itcamp13# Premium conference on Microsoft technologies

Development &

Mobile

• Rng 0: today

• Rng1: 2D games, music, video, apps

• Rng2: Next gen, WebGL

Ringmark

Page 13: ITCamp 2013 - Lorant Domokos - Chasing the one codebase, multiple platforms dream

itcampro@ itcamp13# Premium conference on Microsoft technologies

Development &

Mobile

Page 14: ITCamp 2013 - Lorant Domokos - Chasing the one codebase, multiple platforms dream

itcampro@ itcamp13# Premium conference on Microsoft technologies

Development &

Mobile

• Performance

– The Facebook issue

– The jQuery Mobile issue

• UX?

• 90 percent

Why not?

Page 15: ITCamp 2013 - Lorant Domokos - Chasing the one codebase, multiple platforms dream

itcampro@ itcamp13# Premium conference on Microsoft technologies

Development &

Mobile

• Minimize DOM node instances

• Avoid deeply nested HTML DOM structures

• Use CSS transforms ()

• Use CSS animations & transitions

• Use fixed widths and heights for DOM

elements

• Preload images or assets used in CSS styles

• Be smart with your HTML DOM elemen

• Touch Interactivity

Performance tips

Page 16: ITCamp 2013 - Lorant Domokos - Chasing the one codebase, multiple platforms dream

itcampro@ itcamp13# Premium conference on Microsoft technologies

Development &

Mobile

• How do I make an app that exactly matches

native look and feel for all platforms?

– My response: Don’t.

– 1) this is very difficult to do, and 2) if anything

changes in the OS…

• Uncanny valley

• Respect App Store guidelines

• Create custom identity for your app

• That said…it’s not impossible

UX

Page 17: ITCamp 2013 - Lorant Domokos - Chasing the one codebase, multiple platforms dream

itcampro@ itcamp13# Premium conference on Microsoft technologies

PHONEGAP

Page 18: ITCamp 2013 - Lorant Domokos - Chasing the one codebase, multiple platforms dream

itcampro@ itcamp13# Premium conference on Microsoft technologies

Development &

MobilePhonegap

PhoneGap === Cordova

Page 19: ITCamp 2013 - Lorant Domokos - Chasing the one codebase, multiple platforms dream

itcampro@ itcamp13# Premium conference on Microsoft technologies

Development &

MobileNative

Page 20: ITCamp 2013 - Lorant Domokos - Chasing the one codebase, multiple platforms dream

itcampro@ itcamp13# Premium conference on Microsoft technologies

Development &

MobileHybrid

Page 21: ITCamp 2013 - Lorant Domokos - Chasing the one codebase, multiple platforms dream

itcampro@ itcamp13# Premium conference on Microsoft technologies

Development &

Mobile

Page 22: ITCamp 2013 - Lorant Domokos - Chasing the one codebase, multiple platforms dream

itcampro@ itcamp13# Premium conference on Microsoft technologies

Development &

Mobile

• Accelerometer

• Camera

• Capture : Image, Audio, Video

• Compass

• Contacts

• Connection

• File

• Geolocation

• Media

• Notification

• Storage

• Websocket (Android)

API

Page 23: ITCamp 2013 - Lorant Domokos - Chasing the one codebase, multiple platforms dream

itcampro@ itcamp13# Premium conference on Microsoft technologies

Development &

MobilePhonegap build

Page 24: ITCamp 2013 - Lorant Domokos - Chasing the one codebase, multiple platforms dream

itcampro@ itcamp13# Premium conference on Microsoft technologies

BEST PRACTICES

Page 25: ITCamp 2013 - Lorant Domokos - Chasing the one codebase, multiple platforms dream

itcampro@ itcamp13# Premium conference on Microsoft technologies

Development &

Mobile1. Abstract Data Access

$.ajax({url: "/api/employee/3"}).done(function(employee) {//Do something with employee});

dataAdapter.findById(3).done(function(employee) {//Do something with employee});

VS

Page 26: ITCamp 2013 - Lorant Domokos - Chasing the one codebase, multiple platforms dream

itcampro@ itcamp13# Premium conference on Microsoft technologies

Development &

Mobile

Page 27: ITCamp 2013 - Lorant Domokos - Chasing the one codebase, multiple platforms dream

itcampro@ itcamp13# Premium conference on Microsoft technologies

Development &

Mobile

• Default JavaScript alert gives away the fact

that your application is not native

• PhoneGap API: navigator.notification.alert(message, alertCallback, [title], [buttonName])

• ... but that doesn’t work in your browser

• Solution: Build an abstraction layer

• Display JavaScript alert when running in the

browser

2. Browser runnable

Page 28: ITCamp 2013 - Lorant Domokos - Chasing the one codebase, multiple platforms dream

itcampro@ itcamp13# Premium conference on Microsoft technologies

Development &

Mobile

• Benefits

– Fast

– Works offline

– Control over experience

• Caveats

– More Complex

– Memory management

– Modular Strategy

3. Use Single Page Architecture

Page 29: ITCamp 2013 - Lorant Domokos - Chasing the one codebase, multiple platforms dream

itcampro@ itcamp13# Premium conference on Microsoft technologies

Development &

Mobile

• Benefits

– Maintainable

– Toolable

– Separation of concerns

• Examples

– Mustache.js

– Handlebars.js

– Underscore.js

4. Use Templates

Page 30: ITCamp 2013 - Lorant Domokos - Chasing the one codebase, multiple platforms dream

itcampro@ itcamp13# Premium conference on Microsoft technologies

Development &

Mobile

• Javascript does not give you the right to

disregard SOLID principles

5. Use MV*

Page 31: ITCamp 2013 - Lorant Domokos - Chasing the one codebase, multiple platforms dream

itcampro@ itcamp13# Premium conference on Microsoft technologies

Development &

Mobile6. Consider Frameworks

Page 32: ITCamp 2013 - Lorant Domokos - Chasing the one codebase, multiple platforms dream

itcampro@ itcamp13# Premium conference on Microsoft technologies

Development &

Mobile

• Leverage the browser stack

7. Routing

Page 33: ITCamp 2013 - Lorant Domokos - Chasing the one codebase, multiple platforms dream

itcampro@ itcamp13# Premium conference on Microsoft technologies

Development &

Mobile8. Abstract Device Features

Interaction Mouse Touch

Notification Alert Native

Storage Online Offline

Sensors Unavailable Available

Page 34: ITCamp 2013 - Lorant Domokos - Chasing the one codebase, multiple platforms dream

itcampro@ itcamp13# Premium conference on Microsoft technologies

Development &

Mobile

• alert()

• -webkit-touch-callout: none;

• -webkit-tap-highlight-color:rgba(0, 0, 0, 0);

9. Hide HTMLish Behaviors

Page 35: ITCamp 2013 - Lorant Domokos - Chasing the one codebase, multiple platforms dream

itcampro@ itcamp13# Premium conference on Microsoft technologies

Development &

Mobile

• Don't generate UI on the server

• Don't wait for data to display the UI

• Cache everything (data, selectors, precompiled templates, ...)

• Use Hardware acceleration

• Avoid click event's 300ms delay

• Use CSS sprite sheets

• Limit shadows and gradients

• Avoid re!ows

• Do you need that framework?

• Test

10. Architect for Performance

Page 36: ITCamp 2013 - Lorant Domokos - Chasing the one codebase, multiple platforms dream

itcampro@ itcamp13# Premium conference on Microsoft technologies

KNOCKOUT AND DURANDAL

Page 37: ITCamp 2013 - Lorant Domokos - Chasing the one codebase, multiple platforms dream

itcampro@ itcamp13# Premium conference on Microsoft technologies

Development &

Mobile

• Separation of concerns

• Data binding

– Observable properties

– Observable arrays

– Computed properties

Knockout and MVVM

Page 38: ITCamp 2013 - Lorant Domokos - Chasing the one codebase, multiple platforms dream

itcampro@ itcamp13# Premium conference on Microsoft technologies

Development &

Mobile

• Prism for JavaScript…or something like that

• Handles UI plumbing

– Navigation

– View and ViewModel compositon and binding

– Maintainability

– App lifecycle

– Async

– Convention based

Durandal

Page 39: ITCamp 2013 - Lorant Domokos - Chasing the one codebase, multiple platforms dream

itcampro@ itcamp13# Premium conference on Microsoft technologies

Development &

Mobile

• Separate code into modules

• Load modules on demand

• Bundle, minify, optimize

RequireJS

Page 40: ITCamp 2013 - Lorant Domokos - Chasing the one codebase, multiple platforms dream

itcampro@ itcamp13# Premium conference on Microsoft technologies

BREEZE

Page 41: ITCamp 2013 - Lorant Domokos - Chasing the one codebase, multiple platforms dream

itcampro@ itcamp13# Premium conference on Microsoft technologies

Development &

Mobile

• CRUD operations are only basics

• Relations, object graphs

• Caching, offline

• LINQ like queries

MVVM+S

Page 42: ITCamp 2013 - Lorant Domokos - Chasing the one codebase, multiple platforms dream

itcampro@ itcamp13# Premium conference on Microsoft technologies

TYPESCRIPT

Page 43: ITCamp 2013 - Lorant Domokos - Chasing the one codebase, multiple platforms dream

itcampro@ itcamp13# Premium conference on Microsoft technologies

Development &

Mobile

• TypeScript is a superset of JavaScript

• You can enter pure JavaScript into TypeScript

• TypeScript gives you type safety.

• TypeScript gives you encapsulation.

• TypeScript allows you to organize your code

into Modules and Classes

• Cross compiles into JavaScipt

What is TypeScript

Page 44: ITCamp 2013 - Lorant Domokos - Chasing the one codebase, multiple platforms dream

itcampro@ itcamp13# Premium conference on Microsoft technologies

Development &

Mobile

• Standard JavaScript Code

• Static Typing

• Encapsulation with Modules and Classes

• Classes support Constructors, Properties,

Fields and Functions

• Interfaces

• Lambda Functions =>

• Intellisense and syntax checking

Features

Page 45: ITCamp 2013 - Lorant Domokos - Chasing the one codebase, multiple platforms dream

itcampro@ itcamp13# Premium conference on Microsoft technologies

Development &

Mobile

• exports and imports

• constructor

• extends

• implements

• Interface

• public/private

• … Rest syntax

• => Arrow or lambda functions

• <typename> type conversion

• : assignment

Sintactic sugar

Page 46: ITCamp 2013 - Lorant Domokos - Chasing the one codebase, multiple platforms dream

itcampro@ itcamp13# Premium conference on Microsoft technologies

Development &

MobileCode hierarchy

Module

ClassInterface

FieldsConstructors

PropertiesFunctions

Page 47: ITCamp 2013 - Lorant Domokos - Chasing the one codebase, multiple platforms dream

itcampro@ itcamp13# Premium conference on Microsoft technologies

TOOLING

Page 48: ITCamp 2013 - Lorant Domokos - Chasing the one codebase, multiple platforms dream

itcampro@ itcamp13# Premium conference on Microsoft technologies

Development &

Mobile

• VS 2012, Blend

• WYSIWYG: Dreamweaver, IBM Worklight

IDE

Page 49: ITCamp 2013 - Lorant Domokos - Chasing the one codebase, multiple platforms dream

itcampro@ itcamp13# Premium conference on Microsoft technologies

Development &

Mobile

• The PhoneGap Emulator

– Leverages Chrome and Ripple emulator

– Best in class Chrome developer tools

• On-Device Remote Debugging

– iPhone simulator integration with Safari

– Remote Debugging with Weinre

• Remote web inspector

• HTML, CSS manipulation

• No JS breakpoints

– Good old alert()

Debugging Environments

Page 50: ITCamp 2013 - Lorant Domokos - Chasing the one codebase, multiple platforms dream

itcampro@ itcamp13# Premium conference on Microsoft technologies

Development &

Mobile

• Selenium

– UI atutomation

• Unit testing

– Qunit

– Jasmine

• Code coverage

– JSCover

• PhantomJS

– Headless browser

Testing

Page 51: ITCamp 2013 - Lorant Domokos - Chasing the one codebase, multiple platforms dream

itcampro@ itcamp13# Premium conference on Microsoft technologies

Development &

Mobile

• No exactly a smooth ride

• Integrate tools/libraries one at a time

• Differences between browsers/platforms

• Need Mac for iOS

• Always test on devices

Conclusins

Page 52: ITCamp 2013 - Lorant Domokos - Chasing the one codebase, multiple platforms dream

itcampro@ itcamp13# Premium conference on Microsoft technologies

Q & A