Download - Alloy: Deep Dive, Below The Surface, and Other Nautical Metaphors

Transcript
Page 1: Alloy: Deep Dive, Below The Surface, and Other Nautical Metaphors

ALLOYDEEP DIVE, BELOW THE SURFACE, AND OTHER

NAUTICAL METAPHORS

TiConf US June 28-29 2013

Tremont Hotel in Baltimore #ticonf

Page 2: Alloy: Deep Dive, Below The Surface, and Other Nautical Metaphors

TONY LUKASAVAGEAlloy Lead Engineer @

Appcelerator

@tonylukasavage

[email protected]

Page 3: Alloy: Deep Dive, Below The Surface, and Other Nautical Metaphors

CRASH COURSE

Alloy is an MVC framework for Appcelerator's TitaniumSDK built with Node.js. Through a compilation process it

aims to produce highly optimized, cross-platformJavascript code.

Page 4: Alloy: Deep Dive, Below The Surface, and Other Nautical Metaphors

from on .

CODESTRONG 2012 Breakout session - Alloy (MVC)Application Framework OverviewAppcelerator Video Channel Vimeo

Page 5: Alloy: Deep Dive, Below The Surface, and Other Nautical Metaphors

Models | Views | Controllers | Styles

Page 6: Alloy: Deep Dive, Below The Surface, and Other Nautical Metaphors

var tabGroup = Titanium.UI.createTabGroup();var win1 = Titanium.UI.createWindow({ title:'tab 1', backgroundColor:'#fff'});var tab1 = Titanium.UI.createTab({ title:'tab 1', window:win1});var label1 = Titanium.UI.createLabel({ text:'tab 1'});win1.add(label1);win1.addEventListener('click',function(e){/* ... */});var win2 = Titanium.UI.createWindow({ title:'tab 2', backgroundColor:'#fff'});var tab2 = Titanium.UI.createTab({ title:'tab 2', window:win2});var label2 = Titanium.UI.createLabel({ text:'tab 2'});win2.add(label2);tabGroup.addTab(tab1); tabGroup.addTab(tab2); tabGroup.open();

Page 7: Alloy: Deep Dive, Below The Surface, and Other Nautical Metaphors

DECLARATIVE UI<Alloy> <TabGroup> <Tab title="tab1"> <Window title="tab1" backgroundColor="#fff"> <Label>tab 1</Label> </Window> </Tab> <Tab title="tab2"> <Window title="tab2" backgroundColor="#fff"> <Label>tab 2</Label> </Window> </Tab> </TabGroup></Alloy>

Page 8: Alloy: Deep Dive, Below The Surface, and Other Nautical Metaphors

TSS'Window': { backgroundColor: '#fff', navBarHidden: true}

'Label': { text: L('theString'), color: '#222', height: Ti.UI.SIZE, font: { fontSize: 18, fontWeight: 'normal' }}

'.shadow': { shadowColor: Alloy.CFG.shadowColor, shadowOffset: {x:1,y:2}}

'#index[platform=android]': { exitOnClose: true}

Page 9: Alloy: Deep Dive, Below The Surface, and Other Nautical Metaphors

CONTROLLERSvar memory = ['magic show', 'wear $6000 suit'];function forgetMeNow() { memory.push('took forget-me-now'); setTimeout(function() { memory.pop() }, 1000 * 60 * 60 * 12); }

exports.isNude = function() { return false;}

exports.isThereMoney = function(location) { return location === 'banana stand';}

try { $.someWindow.open();} catch (e) { memory.push("I've made a huge mistake"); forgetMeNow();}

Page 10: Alloy: Deep Dive, Below The Surface, and Other Nautical Metaphors

MODELSexports.definition = { config: { columns: { item: "text", done: "integer", date_completed: "text" }, adapter: { type: "sql", collection_name: "todo" } }, extendModel : function(Model) { _.extend(Model.prototype, { validate : function(attrs) { /* ... */ } }); return Model; }, extendCollection : function(Collection) { _.extend(Collection.prototype, { comparator: function(todo) { return todo.get('done'); } }); return Collection; }}

Page 11: Alloy: Deep Dive, Below The Surface, and Other Nautical Metaphors
Page 12: Alloy: Deep Dive, Below The Surface, and Other Nautical Metaphors

WIDGETS

http://www.danielsefton.com/2012/10/ios-slider-menu-widget-for-titanium-alloy

Page 13: Alloy: Deep Dive, Below The Surface, and Other Nautical Metaphors

SYNC ADAPTERSAlloy + Backbone.jsData persistence abstractionAdapters:

SQLiteRESTACSCouchDB

Page 14: Alloy: Deep Dive, Below The Surface, and Other Nautical Metaphors

BUILTINSBackbone.jsUnderscore.jsMoment.jsTitanium-specific libraries

var moment = require('alloy/moment');

Page 15: Alloy: Deep Dive, Below The Surface, and Other Nautical Metaphors

BEST PRACTICES

Page 16: Alloy: Deep Dive, Below The Surface, and Other Nautical Metaphors

* Standarize coding practices *

* Embedding Expertise *

* CommonJS *

* Parity Issues *

* Optimizations *

Page 17: Alloy: Deep Dive, Below The Surface, and Other Nautical Metaphors

FASTER DEVELOPMENT

Page 18: Alloy: Deep Dive, Below The Surface, and Other Nautical Metaphors

HIGH QUALITY APPS

Page 19: Alloy: Deep Dive, Below The Surface, and Other Nautical Metaphors

H TO THE IZZO

Page 20: Alloy: Deep Dive, Below The Surface, and Other Nautical Metaphors

INSTALLING ALLOY

# latest stable[sudo] npm install -g alloy

# by version[sudo] npm install -g [email protected]

# straight from github[sudo] npm install -g git://github.com/appcelerator/alloy.git

Page 21: Alloy: Deep Dive, Below The Surface, and Other Nautical Metaphors

DYNAMIC STYLING*

Modify and apply styles at runtimeNew APIs

Alloy.createStyle()Alloy.UI.create()Alloy.addClass()Alloy.removeClass()Alloy.resetClass()

*available in Alloy 1.2.0

Page 22: Alloy: Deep Dive, Below The Surface, and Other Nautical Metaphors

LISTVIEW MARKUP*

High performance listsiOS & AndroidTransition made easier with AlloyData binding support

*available in Alloy 1.2.0

Page 23: Alloy: Deep Dive, Below The Surface, and Other Nautical Metaphors

NATIVE MODULESIN MARKUP*

<Module id="paint" module="ti.paint" method="createPaintView" platform="ios,android"/>

*available in Alloy 1.2.0

Page 24: Alloy: Deep Dive, Below The Surface, and Other Nautical Metaphors

DEVICE OPTIMIZATIONSDevice QueriesCompiler ConditionalsConditional Configurations

Page 25: Alloy: Deep Dive, Below The Surface, and Other Nautical Metaphors

ALLOY.JMKpre/post processingModify, beautify, minify, etc...Even or , if you're into that sort ofthing

coffeescript Jade

Page 26: Alloy: Deep Dive, Below The Surface, and Other Nautical Metaphors

OVERRIDESNOTHING IS SACRED

...unless it breaks something

Alloy namespace functionsBackbone.js, Underscore.js, etc...Even the core runtime library (alloy.js)

Page 27: Alloy: Deep Dive, Below The Surface, and Other Nautical Metaphors

CONTROLLEREVENTING

Alloy controllers have Backbone eventingLightweight, yet powerfulLoose coupling

Page 28: Alloy: Deep Dive, Below The Surface, and Other Nautical Metaphors

VIEW MODEL BINDINGdataCollectiondataTransformdataFilter

<TableView id="todoTable" dataCollection="todo" dataFilter="whereFunction" dataTransform="transformFunction"> <Require src="row"/></TableView>

Page 29: Alloy: Deep Dive, Below The Surface, and Other Nautical Metaphors

SOURCE MAPSMaps generated code to source, and vice versaEnables debugging, exceptions, and code processorconfig.json toggling{ "sourcemap": false}

Page 30: Alloy: Deep Dive, Below The Surface, and Other Nautical Metaphors

alloylove.com

Page 31: Alloy: Deep Dive, Below The Surface, and Other Nautical Metaphors

COMMUNITYAll-Stars

Fokke Zandenberg ( )David Bankier ( )Aaron Saunders ( )Jason Kneen ( )Mads Moller ( )Josh Jensen ( )

Twitter at

@fokkezb@davidbankier

@aaronksaunders@jasonkneen

@nappdev@joshj

#tialloyQ&A "alloy" tagAlloy Google Group

Page 32: Alloy: Deep Dive, Below The Surface, and Other Nautical Metaphors

THE FUTURE

Page 33: Alloy: Deep Dive, Below The Surface, and Other Nautical Metaphors

DYNAMIC THEMES

Page 34: Alloy: Deep Dive, Below The Surface, and Other Nautical Metaphors

LIGHTER, MOREPOWERFUL MODELING

Peel back the Alloy layerDevelop abstract model interfaceLeverage Alloy's and framework of choice's features

Page 35: Alloy: Deep Dive, Below The Surface, and Other Nautical Metaphors

NATIVE FORMATSiOS NibAndroid XMLNative formatting optimizations

Page 36: Alloy: Deep Dive, Below The Surface, and Other Nautical Metaphors

PACKAGEMANAGEMENT

meets Iterative development independent of Alloy releasesSame conventions, same results

alloylove.com npm

# Install a widget. Package manifest would determine that it's a widgettpm install someCoolAssWidget

# Install a sync adapter.tmp install syncToMyToaster

Page 38: Alloy: Deep Dive, Below The Surface, and Other Nautical Metaphors

FIND ME

@tonylukasavage

[email protected] drinking whiskey in the next few minutes