Top Banner
65

Robotlegs on Top of Gaia

Nov 18, 2014

Download

Technology

Jesse Warden

Jesse Warden shows you how to utilize Robotlegs on top of Gaia Flash Framework.
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Robotlegs on Top of Gaia
Page 2: Robotlegs on Top of Gaia

WhoWho

Jesse Warden

Flex & Flash Consultant

Career: Director, Flash, Flex

Education: Art, Self-Taught Coder

Page 3: Robotlegs on Top of Gaia

Robotlegs/GaiaRobotlegs/Gaia

Gaia

Robotlegs

Using Them Together

+ =Hot Dog!Hot Dog!

Page 4: Robotlegs on Top of Gaia

Why?Why?

Flash Sites: Scaleable Mess

Flex Sites: Re-invent the wheel ...Badly.

Page 5: Robotlegs on Top of Gaia
Page 6: Robotlegs on Top of Gaia

GaiaGaia

Framework & Toolset for Building Flash Websites

Inspired by Ruby on Rails

Page 7: Robotlegs on Top of Gaia

Gaia InventorGaia InventorSteven SacksGaia Inventor

stevensacks.netTwittah: stevensacks

Page 8: Robotlegs on Top of Gaia

Industry ToolsIndustry Tools

SWFObject

SWFAddress

TweenLite

Thunderbolt

Page 9: Robotlegs on Top of Gaia

Example SitesExample Sites

Client SitesClient SitesMercedes, Disney, Rolling Rock, Honda, Mercedes, Disney, Rolling Rock, Honda, Burn After Reading, Keith Urban, Burn After Reading, Keith Urban, Dermalogica, Absolut, Star Trek Movie, Dermalogica, Absolut, Star Trek Movie, Electronic Arts: Tiberium, NIP/Tuck, 180 Electronic Arts: Tiberium, NIP/Tuck, 180 Energy DrinkEnergy Drink

Page 10: Robotlegs on Top of Gaia

Site XMLSite XML

<site title="Gaia Scaffold Site"> <page id="index" src="index.swf">

<page id="nav" src="nav.swf"> <page id="home"

src="home.swf" title="Home">

<asset id=”music” src=”rock.mp3”/>

</page> </page> </page></site>

Page 11: Robotlegs on Top of Gaia

ScaffoldingScaffolding

Page 12: Robotlegs on Top of Gaia

Gaia’s APIGaia’s API

goto();

Page 13: Robotlegs on Top of Gaia

TransitionsTransitions

transitionIn();

transitionOut();

transitioninComplete();

transitionOutComplete();

Page 14: Robotlegs on Top of Gaia

FlowsFlows

Normal

Preload

Reverse

Cross

Page 15: Robotlegs on Top of Gaia

DepthDepth

Page 16: Robotlegs on Top of Gaia

AssetsAssets

Page 17: Robotlegs on Top of Gaia

PreloadingPreloading

multiple Files, Byte Accuracy

Override Runtime API

Pre-loaders for Pages

Pre-loaders for Assets

Page 18: Robotlegs on Top of Gaia

Other FeaturesOther Features

SEO Scaffolding (yes, it works)

DEEPlinking API on top of SWFAddress

Bindings support in Site.xml

Page 19: Robotlegs on Top of Gaia

GaiaGaia

Bread and Butter

Page 20: Robotlegs on Top of Gaia

RobotlegsRobotlegs

MVCS Framework

ActionScript 3

Page 21: Robotlegs on Top of Gaia

RobotlegsRobotlegs

Pure AS3 = Yes

Flex = Yes

AIR = Yes

Flash = Yes (CS4/CS5)

Page 22: Robotlegs on Top of Gaia

RobotlegsRobotlegsShaun Smith

Robotlegs Inventor

Shaun.boyblack.co.zaTwittah: darscan

Page 23: Robotlegs on Top of Gaia

RobotlegsRobotlegs

Comes with a Reference Implementation (MVCS)

Robert Penner’s “Signals”

Elad Elrom’s “Passive View Example”

AsyncCommand

Page 24: Robotlegs on Top of Gaia

Dependency INjectionDependency INjection

The New “New”

All you need to know: [Inject]

SWiftSuspenders

SmartyPants IoC

GUICE: A Different Java Spring

Page 25: Robotlegs on Top of Gaia

Dependency InjectionDependency Injection

Solves PureMVC’s Casting Problem

var myView: viewObject as MainView;

var proxy:MyProxy = facade.retreiveProxy(MyProxy.NAME) as MyProxy;

Easier to code to Interfaces

Page 26: Robotlegs on Top of Gaia

DI ExampleDI Example

private var proxy:MyProxy;

var proxy:MyProxy = facade.retreiveProxy(MyProxy.NAME) as MyProxy;trace(proxy.myVO);

---------------------------

[Inject]public var model:MyModel

trace(model.myVO);

Page 27: Robotlegs on Top of Gaia
Page 28: Robotlegs on Top of Gaia

EventsEvents

Communications Through Events

Page 29: Robotlegs on Top of Gaia

Event GotchasEvent Gotchas

Tons

Sub-Systems

More Events > More properties

Page 30: Robotlegs on Top of Gaia
Page 31: Robotlegs on Top of Gaia

ViewView

GUIGUI

FormForm

ChartChart

Video PlayerVideo Player

List of ImagesList of Images

Page 32: Robotlegs on Top of Gaia

Dumb ViewDumb View

Dumb

2 things

1. Accept Data

2. Dispatch User Gestures

Page 33: Robotlegs on Top of Gaia
Page 34: Robotlegs on Top of Gaia

ValueObjectValueObject

HOld “Value”

2nd Most Valuable Class

Strongly Typed

Can Differ From Server to help GUI

Page 35: Robotlegs on Top of Gaia

VO GotchasVO Gotchas

To Build yerself...

...or have a Factory do it

constructor Params foil Serialization

Use Optional Values if you must

It changes, affects Entire App

Page 36: Robotlegs on Top of Gaia

RobotlegsRobotlegs

Context

Mediator

Services

Model

Command

Actor (Base Class)

Page 37: Robotlegs on Top of Gaia
Page 38: Robotlegs on Top of Gaia

ContextContext

Initialize FrameworkInitialize Framework

Event BusEvent Bus

Multiple Contexts for Modular Multiple Contexts for Modular DevelopmentDevelopment

Page 39: Robotlegs on Top of Gaia

ActorActor

Base Class for Model and Service

Has Context Injected

Base Class to communicate to the Framework

Page 40: Robotlegs on Top of Gaia
Page 41: Robotlegs on Top of Gaia

MediatorMediator

Mediator PatternMediator Pattern

View Communicate w/ FrameworkView Communicate w/ Framework

1 View per Mediator1 View per Mediator

Keeps Framework outKeeps Framework out

Not all views need MediatorsNot all views need Mediators

Page 42: Robotlegs on Top of Gaia
Page 43: Robotlegs on Top of Gaia

ServiceService

Retrieve and/or Send Data

Remote and/or Local Services

Parse Data to VO’s

Dispatch Success or Failure

Don’t Listen to Framework Events

Great Unit Test Candidates

Page 44: Robotlegs on Top of Gaia

Service PracticesService Practices

Doesn’t Store Data

Dispatch Event, has Data in It

Extend Actor

Store’s Data

Dispatch Event, NO Data in It

Extend EventDispatcher

Page 45: Robotlegs on Top of Gaia

Service Gotcha’sService Gotcha’s

Foreign DataForeign Data

FActoriesFActories::#1 Source of Bugs#1 Source of Bugs

Compiler Doesn’tCompiler Doesn’tHelp youHelp you

Manual TimeoutsManual Timeouts

Explode EarlyExplode Early

Page 46: Robotlegs on Top of Gaia
Page 47: Robotlegs on Top of Gaia

Model(s)Model(s)

Observer Pattern

Stores Global Data

Usually Wraps a VO

Doesn’t Listen for Framework Events

Dispatches Data Changes

Persists

Extends Actor

Page 48: Robotlegs on Top of Gaia

Model(s)Model(s)

Re-Factor to:

Data needs to persist

1> Mediator/Command Use Data

Page 49: Robotlegs on Top of Gaia
Page 50: Robotlegs on Top of Gaia

CommandCommand

Command Pattern

Controller Work

DRY

Re-Factor To

Doesn’t Listen to Framework Events

Page 51: Robotlegs on Top of Gaia

Command ExampleCommand Example

Login Form

Update Profile

Edit Server Data

Page 52: Robotlegs on Top of Gaia

User GesturesUser Gestures

Command’s are Usually User Gestures

Login, Logout, SaveUser

AddTag

Save

Page 53: Robotlegs on Top of Gaia

Command Pro’sCommand Pro’s

DRY

Centralized Logic

Data Problem = 2 places to look

1. Service

2. Command

Not Hunting Through Mediators

RAD (Rapid Application Development)

Page 54: Robotlegs on Top of Gaia

COmmand Con’sCOmmand Con’s

Code Bloat Early in Project

Handling Context Sensitive Data?...2 Commands

20 User Gestures = 40 Commands

Commands for Everything

Page 55: Robotlegs on Top of Gaia
Page 56: Robotlegs on Top of Gaia

AsyncCommandAsyncCommand

Asynchronous Command

Why?

Java/C/C++ Devs Invented Command Pattern

Blocking Language

Executes Server Request and Codepauses

Page 57: Robotlegs on Top of Gaia

AsyncCommandAsyncCommand

ActionScript is not Blocking

It is Asynchronous

Sometimes things need to wait

To wait, they need context

To have context, they need to exist

Commands die immediately

Page 58: Robotlegs on Top of Gaia

AsyncCommandAsyncCommand

AsyncCommand’s do not Block

You Control when they die

You can handle Server responseswith Context

React & Respond w/ Less code

fork to call other Commands

Page 59: Robotlegs on Top of Gaia

Gaia + RobotlegsGaia + Robotlegs

Gaia builds yer Site

Robotlegs Handles:

Business Logic

Application Logic

+

Page 60: Robotlegs on Top of Gaia

Why?Why?

Agency

Shields from Ever Changing client Visuals

View Changes, App/Biz Logic Doesn’t

Dev

Don’t Break Gaia’s modules

RAD & Scaleable

Page 61: Robotlegs on Top of Gaia

How?How?

Export SWC “Magic Checkbox”

Page 62: Robotlegs on Top of Gaia

Step by StepStep by Step

1. Setup Gaia Project

2. Register Context in Main.as

3. Page or child View implement Interface

4. Register Interface for Mediator

Page 63: Robotlegs on Top of Gaia

Rules n’ GotchasRules n’ Gotchas

Interface for Bridge Pattern

Gaia Pages use Bridge Pattern

Not all Gaia Pages need a Mediator

Page 64: Robotlegs on Top of Gaia

ConclusionsConclusions

Gaia is the Foundation for Site

Robotlegs Handles Biz & App Logic

Together, they Build a Scaleable & Flexible Site

Page 65: Robotlegs on Top of Gaia

Questions?Questions?

Jesse WardenJesse Warden

Twittah: jesterxlTwittah: jesterxl

jessewarden.comjessewarden.com