SlideShare a Scribd company logo
1 of 78
MAXIMIZING CODE
 REUSE ACROSS SCREENS
                              Flash Builder 4.5 and Flex SDK 4.5
                                    (including mobile Flex)




www.jasonhanson.com/360flex
Your Presenter
             • Jason Hanson
                • twitter @jayfour000
                • flexfood.blogspot.com
                • www.jasonhanson.com
             • Building for Flash Platform since 1999
             • Working with Hero SDK since Aug,
               2010 (beta)
www.jasonhanson.com/360flex
Stuff to check out if
                   you get bored

       • http://www.jasonhanson.com/360flex




www.jasonhanson.com/360flex
• All photos © Michael Schoenewies
               @atomic_playboy




www.jasonhanson.com/360flex
So many screens
                           So little time
             • Desktop
             • Laptop
             • Phone
             • Tablet
             • TV
             • Car Dashboard
             • Fridge, windows, clothing, coffee table
www.jasonhanson.com/360flex
All Very Different
       • OS
       • Size, Shape
       • User Interaction
       • Pixel Density
       • Passive vs Active          © @atomic_playboy



         Experience


www.jasonhanson.com/360flex
LOCATION, Location,
                      location
       • Take your business to your users
       • Your business stays the same
       • Your apps need to change based on how
         the user interactions with the screen of
         their choosing
       • Your business should seamlessly flow
         between screens

www.jasonhanson.com/360flex
Drink the Kool-Aid?




www.jasonhanson.com/360flex
Drink the Kool-Aid?




www.jasonhanson.com/360flex
Flash Platform
                     Offers One Option
             • Write core business code once
             • Reuse on each new screen target
             • Build custom views appropriate for
               each screen target
             • Modify core code as needed for
               special cases



www.jasonhanson.com/360flex
www.jasonhanson.com/360flex
Code Reuse with
Flash Builder 4.5
Code Reuse with
Flash Builder 4.5
      core
       lib
Code Reuse with
Flash Builder 4.5
      core
       lib



               Web
Code Reuse with
Flash Builder 4.5
      core
       lib



               Web



     AIR for
     Desktop
Code Reuse with
    Flash Builder 4.5
           core
            lib



                    Web



          AIR for
Android
          Desktop
Code Reuse with
    Flash Builder 4.5
           core
            lib



  iOS               Web



          AIR for
Android
          Desktop
Code Reuse with
    Flash Builder 4.5
           core
            lib



  iOS                 Web



          AIR for
Android             AIR for *
          Desktop
Code Reuse with
    Flash Builder 4.5
           core
            lib



  iOS                 Web



          AIR for
Android             AIR for *
          Desktop
Code Reuse with
    Flash Builder 4.5
                 core
                  lib



  iOS     view            Web
           lib


            AIR for
Android                 AIR for *
            Desktop
Code Reuse with
    Flash Builder 4.5
                 core
                  lib



  iOS     view      view     Web
           lib       lib


            AIR for
Android                    AIR for *
            Desktop
Code Reuse with
    Flash Builder 4.5
                 core           test
                  lib         runner



  iOS     view      view     Web
           lib       lib


            AIR for
Android                    AIR for *
            Desktop
www.jasonhanson.com/360flex
core
        lib                   core lib
             • Business Logic
                • .model
                • .controller
                • .presenter
                • .service
                • .event
             • No view code
www.jasonhanson.com/360flex
core
        lib                   core lib
             • Flex Library Project
             • Remove “view” libs from Library path
             • Keep framework.swc for data classes
               like ArrayCollection and BindingUtils
             • Keep rpc.swc for HTTPService and
               AsyncToken



www.jasonhanson.com/360flex
core
        lib                   core lib


                               keep:
                               framework.swc
                               rpc.swc




                                remove view libraries


www.jasonhanson.com/360flex
test
      runner                  Test Runner
             • Flex Project
             • FlexUnit 4 built
               into FlashBuilder
             • You can build
               out most of the
               core lib with
               only unit tests
             • Mock services
www.jasonhanson.com/360flex
Screen Targets
             • Web (.swf)
             • AIR (.air)
             • AIR for Android (.apk)
             • iOS (.ipa)
             • AIR for BlackBerry Playbook (.bar)
             • AIR for * (.***)


www.jasonhanson.com/360flex
www.jasonhanson.com/360flex
Your Projects Might
                        Look Like This




www.jasonhanson.com/360flex
Tips for
                              AS3 Projects




www.jasonhanson.com/360flex
Tips for
                              AS3 Projects




www.jasonhanson.com/360flex
www.jasonhanson.com/360flex
Architecture
             • MVC (with presenters)                       i es     controller
                                                       e rt
                                                   r op
                                                  p




                                                                                        method
                • Model                      re




                                                                                         calls
                                           o




                                                                     event
                                      st


                • View
                • Presenter        model                             presenter




                                                                                event
                • Controller



                                                                  method
                                                                   calls
             • Passive view
                                                                             view
                                                                             view
                                                                              view
                                                                              view
                                                                               view
www.jasonhanson.com/360flex
presenter
                              Presenter
             • Same basic concept as Presentation Model
                • Separates business logic from view
             • Views change more frequently then any
               other part of the app
             • Views for different screen targets may
               have vastly different display code



www.jasonhanson.com/360flex
presenter
                              Presenter
             • Public methods to do ‘stuff’
             • Contract exposed with interface
             • Communicates by dispatching events
                • Dispatches events to controller
                • Dispatches events to views
             • Never holds instance of views


www.jasonhanson.com/360flex
presenter
                              Presenter
             • Why Bother?
                • Same presenter can be used for multiple
                  views in multiple screen target apps
                • Code in presenters can be unit tested,
                  while code in views is often very hard to
                  test



www.jasonhanson.com/360flex
controller
                              Controller
             • Control messaging (Grand Central)
             • Manage state
             • Listen for events from presenters
             • Make service calls
             • Set properties on presenters
             • Set properties on the models


www.jasonhanson.com/360flex
model
                              Model
             • Hold instances of top-level presenters
             • Sparingly hold instances of data
               shared between multiple presenters
             • Singleton
                • Easy to ‘inject
                • Only place a singleton is used
             • Not an IEventDispatcher
www.jasonhanson.com/360flex
view
         view
          view
          view
           view               View
             • Never in core lib
             • Screen specific display code
             • Holds instance of presenter (interface)
             • Makes function calls on presenter
             • Listens to events on presenter
             • Holds little or no data


www.jasonhanson.com/360flex
view
         view
          view
          view
           view               View




www.jasonhanson.com/360flex
view
         view
          view
          view
           view               View




www.jasonhanson.com/360flex
view
         view
                              Screen
          view
          view
           view               Targets
             • View code is “throw-away” code
             • Resist the urge to over-engineer views
             • Often faster to just rewrite view code
               then it is to build configurable
               components
             • Screen specific view code



www.jasonhanson.com/360flex
view
         view
                              Screen
          view
          view
           view               Targets




www.jasonhanson.com/360flex
view
         view
                              Screen
          view
          view
           view               Targets




www.jasonhanson.com/360flex
view
         view
                              Screen
          view
          view
           view               Targets




www.jasonhanson.com/360flex
view
         view
                              Screen
          view
          view
           view               Targets




www.jasonhanson.com/360flex
view
         view
                              Screen
          view
          view
           view               Targets




www.jasonhanson.com/360flex
www.jasonhanson.com/360flex
www.jasonhanson.com/360flex
Application State
             • Application state per functional area
             • Presenter for each application state
             • Presenter to view ratio may not be 1:1
             • Some views may reuse the same
               presenter




www.jasonhanson.com/360flex
Application State
             • Presenter currentState property
             • For MXML view bind the
               presenter.currentState to the currentState
               of the view
             • Change state on the presenter changes
               state on the view
             • In most cases views and presenters do not
               modify currentState, the controller does
www.jasonhanson.com/360flex
Application State




www.jasonhanson.com/360flex
Tip: No States as a
          String-Based Contracts
             • Bad idea in general
             • Typos break apps at runtime :(
             • Use enums or constants for state
               names
             • Spark state name property does not
               support constants values. Must use a
               string in this case.

www.jasonhanson.com/360flex
State Enum




www.jasonhanson.com/360flex
Spark States



                                     User error failure point.
                                     Strings not compile checked
                                     against enum.




www.jasonhanson.com/360flex
ViewNavigator
                         State Translator

             • Mobile View-Based Applications use a
               ViewNavigator
                • Similar to a stack of cards
                • pushView(viewClass:Class, ....)
                • replaceView()
                • popView(), popToFirstView()
                • not state friendly by default
www.jasonhanson.com/360flex
ViewNavigator
                         State Translator
                • ViewNavigator methods require a
                  view class type
                • State is held in the ‘core’ presenters
                • Presenters have no knowledge of
                  screen-specific view classes
                • Need to translate states to view
                  classes

www.jasonhanson.com/360flex
ViewNavigator
                         State Translator




www.jasonhanson.com/360flex
ViewNavigator
                         State Translator




www.jasonhanson.com/360flex
ViewNavigator
                         State Translator




www.jasonhanson.com/360flex
www.jasonhanson.com/360flex
Let’s Look at
                               Some Code
             • Show code
             • Show apps running on devices
             • Try not to break it




www.jasonhanson.com/360flex
www.jasonhanson.com/360flex
Where to go
                              From Here?
             • Get Flash Builder 4.5
             • Check out other talks this week for
               more details on different parts of what
               I covered today
             • Go build something!




www.jasonhanson.com/360flex
END
                              (almost)




www.jasonhanson.com/360flex
Advert:
                              My Other Talk
             • Deep Dive into Flex Mobile Item
               Renderers
             • Wed 10:50am - 12:00pm
             • Snip from that preso on next slide




www.jasonhanson.com/360flex
www.jasonhanson.com/360flex
END




www.jasonhanson.com/360flex
Intentional Left
                      Blank


www.jasonhanson.com/360flex
• Extra Slides After This Point




www.jasonhanson.com/360flex
State Enum




www.jasonhanson.com/360flex
www.jasonhanson.com/360flex
Test Runner Project




www.jasonhanson.com/360flex
Deploying




www.jasonhanson.com/360flex
www.jasonhanson.com/360flex
www.jasonhanson.com/360flex
www.jasonhanson.com/360flex

More Related Content

Viewers also liked

Software reuse, repurposing and reproducibility
Software reuse, repurposing and reproducibilitySoftware reuse, repurposing and reproducibility
Software reuse, repurposing and reproducibilityJisc
 
Standard Coding, OOP Techniques and Code Reuse
Standard Coding, OOP Techniques and Code ReuseStandard Coding, OOP Techniques and Code Reuse
Standard Coding, OOP Techniques and Code ReuseRayhan Chowdhury
 
Software Reuse: Challenges and Business Success
Software Reuse: Challenges and Business SuccessSoftware Reuse: Challenges and Business Success
Software Reuse: Challenges and Business SuccessUniversity of Zurich
 
Software Reuse and Object-Oriented Programming
Software Reuse and Object-Oriented ProgrammingSoftware Reuse and Object-Oriented Programming
Software Reuse and Object-Oriented Programmingkim.mens
 
Software reuse ppt.
Software reuse ppt.Software reuse ppt.
Software reuse ppt.Sumit Biswas
 

Viewers also liked (6)

Software reuse, repurposing and reproducibility
Software reuse, repurposing and reproducibilitySoftware reuse, repurposing and reproducibility
Software reuse, repurposing and reproducibility
 
Standard Coding, OOP Techniques and Code Reuse
Standard Coding, OOP Techniques and Code ReuseStandard Coding, OOP Techniques and Code Reuse
Standard Coding, OOP Techniques and Code Reuse
 
Software Reuse: Challenges and Business Success
Software Reuse: Challenges and Business SuccessSoftware Reuse: Challenges and Business Success
Software Reuse: Challenges and Business Success
 
Software Reuse and Object-Oriented Programming
Software Reuse and Object-Oriented ProgrammingSoftware Reuse and Object-Oriented Programming
Software Reuse and Object-Oriented Programming
 
Software reuse ppt.
Software reuse ppt.Software reuse ppt.
Software reuse ppt.
 
Ch15 software reuse
Ch15 software reuseCh15 software reuse
Ch15 software reuse
 

Similar to Maximizing Code Reuse Across Screens

Deep dive into share point framework webparts
Deep dive into share point framework webpartsDeep dive into share point framework webparts
Deep dive into share point framework webpartsPrabhu Nehru
 
State of the Mobile Web Frameworks
State of the Mobile Web FrameworksState of the Mobile Web Frameworks
State of the Mobile Web FrameworksJesse Palmer
 
[2015/2016] Apache Cordova
[2015/2016] Apache Cordova[2015/2016] Apache Cordova
[2015/2016] Apache CordovaIvano Malavolta
 
Building mobile apps with PhoneGap and Backbone
Building mobile apps with PhoneGap and BackboneBuilding mobile apps with PhoneGap and Backbone
Building mobile apps with PhoneGap and BackboneTroy Miles
 
360|Flex Recap - San Jose 2010
360|Flex Recap - San Jose 2010360|Flex Recap - San Jose 2010
360|Flex Recap - San Jose 2010David Ortinau
 
Your choices for building a mobile app in 2016
Your choices for building a mobile app in 2016Your choices for building a mobile app in 2016
Your choices for building a mobile app in 2016Jad Salhani
 
JVx with VisionX and Oracle Forms integration
JVx with VisionX and Oracle Forms integrationJVx with VisionX and Oracle Forms integration
JVx with VisionX and Oracle Forms integrationSIB Visions GmbH
 
React native - React(ive) Way To Build Native Mobile Apps
React native - React(ive) Way To Build Native Mobile AppsReact native - React(ive) Way To Build Native Mobile Apps
React native - React(ive) Way To Build Native Mobile AppsJimit Shah
 
From RPG OA to Node.js: Approaches to Application Modernization - Greg Patterson
From RPG OA to Node.js: Approaches to Application Modernization - Greg PattersonFrom RPG OA to Node.js: Approaches to Application Modernization - Greg Patterson
From RPG OA to Node.js: Approaches to Application Modernization - Greg PattersonFresche Solutions
 
Building Effective and Rapid Applications with IBM MobileFirst Platform
Building Effective and Rapid Applications with IBM MobileFirst PlatformBuilding Effective and Rapid Applications with IBM MobileFirst Platform
Building Effective and Rapid Applications with IBM MobileFirst PlatformAndrew Ferrier
 
PLAT-20 Building Alfresco Prototypes in a Few Hours
PLAT-20 Building Alfresco Prototypes in a Few HoursPLAT-20 Building Alfresco Prototypes in a Few Hours
PLAT-20 Building Alfresco Prototypes in a Few HoursAlfresco Software
 
Rise of the hybrids
Rise of the hybridsRise of the hybrids
Rise of the hybridsOron Ben Zvi
 
React native starter
React native starterReact native starter
React native starterNhan Cao
 
Uncovering the Latest in SharePoint Development
Uncovering the Latest in SharePoint DevelopmentUncovering the Latest in SharePoint Development
Uncovering the Latest in SharePoint DevelopmentEric Overfield
 
Publishing API documentation -- Workshop
Publishing API documentation -- WorkshopPublishing API documentation -- Workshop
Publishing API documentation -- WorkshopTom Johnson
 

Similar to Maximizing Code Reuse Across Screens (20)

Deep dive into share point framework webparts
Deep dive into share point framework webpartsDeep dive into share point framework webparts
Deep dive into share point framework webparts
 
State of the Mobile Web Frameworks
State of the Mobile Web FrameworksState of the Mobile Web Frameworks
State of the Mobile Web Frameworks
 
Xamarin v.Now
Xamarin v.NowXamarin v.Now
Xamarin v.Now
 
[2015/2016] Apache Cordova
[2015/2016] Apache Cordova[2015/2016] Apache Cordova
[2015/2016] Apache Cordova
 
Firefox OS Weekend
Firefox OS WeekendFirefox OS Weekend
Firefox OS Weekend
 
WCM-7 Surfing with CMIS
WCM-7 Surfing with CMISWCM-7 Surfing with CMIS
WCM-7 Surfing with CMIS
 
Building mobile apps with PhoneGap and Backbone
Building mobile apps with PhoneGap and BackboneBuilding mobile apps with PhoneGap and Backbone
Building mobile apps with PhoneGap and Backbone
 
Mobile app development
Mobile app development  Mobile app development
Mobile app development
 
360|Flex Recap - San Jose 2010
360|Flex Recap - San Jose 2010360|Flex Recap - San Jose 2010
360|Flex Recap - San Jose 2010
 
Your choices for building a mobile app in 2016
Your choices for building a mobile app in 2016Your choices for building a mobile app in 2016
Your choices for building a mobile app in 2016
 
JVx with VisionX and Oracle Forms integration
JVx with VisionX and Oracle Forms integrationJVx with VisionX and Oracle Forms integration
JVx with VisionX and Oracle Forms integration
 
React native - React(ive) Way To Build Native Mobile Apps
React native - React(ive) Way To Build Native Mobile AppsReact native - React(ive) Way To Build Native Mobile Apps
React native - React(ive) Way To Build Native Mobile Apps
 
O365: Attack of the Clones
O365: Attack of the ClonesO365: Attack of the Clones
O365: Attack of the Clones
 
From RPG OA to Node.js: Approaches to Application Modernization - Greg Patterson
From RPG OA to Node.js: Approaches to Application Modernization - Greg PattersonFrom RPG OA to Node.js: Approaches to Application Modernization - Greg Patterson
From RPG OA to Node.js: Approaches to Application Modernization - Greg Patterson
 
Building Effective and Rapid Applications with IBM MobileFirst Platform
Building Effective and Rapid Applications with IBM MobileFirst PlatformBuilding Effective and Rapid Applications with IBM MobileFirst Platform
Building Effective and Rapid Applications with IBM MobileFirst Platform
 
PLAT-20 Building Alfresco Prototypes in a Few Hours
PLAT-20 Building Alfresco Prototypes in a Few HoursPLAT-20 Building Alfresco Prototypes in a Few Hours
PLAT-20 Building Alfresco Prototypes in a Few Hours
 
Rise of the hybrids
Rise of the hybridsRise of the hybrids
Rise of the hybrids
 
React native starter
React native starterReact native starter
React native starter
 
Uncovering the Latest in SharePoint Development
Uncovering the Latest in SharePoint DevelopmentUncovering the Latest in SharePoint Development
Uncovering the Latest in SharePoint Development
 
Publishing API documentation -- Workshop
Publishing API documentation -- WorkshopPublishing API documentation -- Workshop
Publishing API documentation -- Workshop
 

More from Jason Hanson

Reinvent yourself - How to become a native iOS developer in nine steps
Reinvent yourself - How to become a native iOS developer in nine stepsReinvent yourself - How to become a native iOS developer in nine steps
Reinvent yourself - How to become a native iOS developer in nine stepsJason Hanson
 
Mobile Flex - Flash Camp St. Louis
Mobile Flex - Flash Camp St. LouisMobile Flex - Flash Camp St. Louis
Mobile Flex - Flash Camp St. LouisJason Hanson
 
OO JS for AS3 Devs
OO JS for AS3 DevsOO JS for AS3 Devs
OO JS for AS3 DevsJason Hanson
 
Deep Dive into Flex Mobile Item Renderers
Deep Dive into Flex Mobile Item RenderersDeep Dive into Flex Mobile Item Renderers
Deep Dive into Flex Mobile Item RenderersJason Hanson
 

More from Jason Hanson (6)

HelloGit
HelloGitHelloGit
HelloGit
 
Reinvent yourself - How to become a native iOS developer in nine steps
Reinvent yourself - How to become a native iOS developer in nine stepsReinvent yourself - How to become a native iOS developer in nine steps
Reinvent yourself - How to become a native iOS developer in nine steps
 
Mobile Flex - Flash Camp St. Louis
Mobile Flex - Flash Camp St. LouisMobile Flex - Flash Camp St. Louis
Mobile Flex - Flash Camp St. Louis
 
OO JS for AS3 Devs
OO JS for AS3 DevsOO JS for AS3 Devs
OO JS for AS3 Devs
 
Deep Dive into Flex Mobile Item Renderers
Deep Dive into Flex Mobile Item RenderersDeep Dive into Flex Mobile Item Renderers
Deep Dive into Flex Mobile Item Renderers
 
Burrito and Hero
Burrito and HeroBurrito and Hero
Burrito and Hero
 

Recently uploaded

New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 

Recently uploaded (20)

New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 

Maximizing Code Reuse Across Screens

  • 1. MAXIMIZING CODE REUSE ACROSS SCREENS Flash Builder 4.5 and Flex SDK 4.5 (including mobile Flex) www.jasonhanson.com/360flex
  • 2. Your Presenter • Jason Hanson • twitter @jayfour000 • flexfood.blogspot.com • www.jasonhanson.com • Building for Flash Platform since 1999 • Working with Hero SDK since Aug, 2010 (beta) www.jasonhanson.com/360flex
  • 3. Stuff to check out if you get bored • http://www.jasonhanson.com/360flex www.jasonhanson.com/360flex
  • 4. • All photos © Michael Schoenewies @atomic_playboy www.jasonhanson.com/360flex
  • 5. So many screens So little time • Desktop • Laptop • Phone • Tablet • TV • Car Dashboard • Fridge, windows, clothing, coffee table www.jasonhanson.com/360flex
  • 6. All Very Different • OS • Size, Shape • User Interaction • Pixel Density • Passive vs Active © @atomic_playboy Experience www.jasonhanson.com/360flex
  • 7. LOCATION, Location, location • Take your business to your users • Your business stays the same • Your apps need to change based on how the user interactions with the screen of their choosing • Your business should seamlessly flow between screens www.jasonhanson.com/360flex
  • 10. Flash Platform Offers One Option • Write core business code once • Reuse on each new screen target • Build custom views appropriate for each screen target • Modify core code as needed for special cases www.jasonhanson.com/360flex
  • 12. Code Reuse with Flash Builder 4.5
  • 13. Code Reuse with Flash Builder 4.5 core lib
  • 14. Code Reuse with Flash Builder 4.5 core lib Web
  • 15. Code Reuse with Flash Builder 4.5 core lib Web AIR for Desktop
  • 16. Code Reuse with Flash Builder 4.5 core lib Web AIR for Android Desktop
  • 17. Code Reuse with Flash Builder 4.5 core lib iOS Web AIR for Android Desktop
  • 18. Code Reuse with Flash Builder 4.5 core lib iOS Web AIR for Android AIR for * Desktop
  • 19. Code Reuse with Flash Builder 4.5 core lib iOS Web AIR for Android AIR for * Desktop
  • 20. Code Reuse with Flash Builder 4.5 core lib iOS view Web lib AIR for Android AIR for * Desktop
  • 21. Code Reuse with Flash Builder 4.5 core lib iOS view view Web lib lib AIR for Android AIR for * Desktop
  • 22. Code Reuse with Flash Builder 4.5 core test lib runner iOS view view Web lib lib AIR for Android AIR for * Desktop
  • 24. core lib core lib • Business Logic • .model • .controller • .presenter • .service • .event • No view code www.jasonhanson.com/360flex
  • 25. core lib core lib • Flex Library Project • Remove “view” libs from Library path • Keep framework.swc for data classes like ArrayCollection and BindingUtils • Keep rpc.swc for HTTPService and AsyncToken www.jasonhanson.com/360flex
  • 26. core lib core lib keep: framework.swc rpc.swc remove view libraries www.jasonhanson.com/360flex
  • 27. test runner Test Runner • Flex Project • FlexUnit 4 built into FlashBuilder • You can build out most of the core lib with only unit tests • Mock services www.jasonhanson.com/360flex
  • 28. Screen Targets • Web (.swf) • AIR (.air) • AIR for Android (.apk) • iOS (.ipa) • AIR for BlackBerry Playbook (.bar) • AIR for * (.***) www.jasonhanson.com/360flex
  • 30. Your Projects Might Look Like This www.jasonhanson.com/360flex
  • 31. Tips for AS3 Projects www.jasonhanson.com/360flex
  • 32. Tips for AS3 Projects www.jasonhanson.com/360flex
  • 34. Architecture • MVC (with presenters) i es controller e rt r op p method • Model re calls o event st • View • Presenter model presenter event • Controller method calls • Passive view view view view view view www.jasonhanson.com/360flex
  • 35. presenter Presenter • Same basic concept as Presentation Model • Separates business logic from view • Views change more frequently then any other part of the app • Views for different screen targets may have vastly different display code www.jasonhanson.com/360flex
  • 36. presenter Presenter • Public methods to do ‘stuff’ • Contract exposed with interface • Communicates by dispatching events • Dispatches events to controller • Dispatches events to views • Never holds instance of views www.jasonhanson.com/360flex
  • 37. presenter Presenter • Why Bother? • Same presenter can be used for multiple views in multiple screen target apps • Code in presenters can be unit tested, while code in views is often very hard to test www.jasonhanson.com/360flex
  • 38. controller Controller • Control messaging (Grand Central) • Manage state • Listen for events from presenters • Make service calls • Set properties on presenters • Set properties on the models www.jasonhanson.com/360flex
  • 39. model Model • Hold instances of top-level presenters • Sparingly hold instances of data shared between multiple presenters • Singleton • Easy to ‘inject • Only place a singleton is used • Not an IEventDispatcher www.jasonhanson.com/360flex
  • 40. view view view view view View • Never in core lib • Screen specific display code • Holds instance of presenter (interface) • Makes function calls on presenter • Listens to events on presenter • Holds little or no data www.jasonhanson.com/360flex
  • 41. view view view view view View www.jasonhanson.com/360flex
  • 42. view view view view view View www.jasonhanson.com/360flex
  • 43. view view Screen view view view Targets • View code is “throw-away” code • Resist the urge to over-engineer views • Often faster to just rewrite view code then it is to build configurable components • Screen specific view code www.jasonhanson.com/360flex
  • 44. view view Screen view view view Targets www.jasonhanson.com/360flex
  • 45. view view Screen view view view Targets www.jasonhanson.com/360flex
  • 46. view view Screen view view view Targets www.jasonhanson.com/360flex
  • 47. view view Screen view view view Targets www.jasonhanson.com/360flex
  • 48. view view Screen view view view Targets www.jasonhanson.com/360flex
  • 51. Application State • Application state per functional area • Presenter for each application state • Presenter to view ratio may not be 1:1 • Some views may reuse the same presenter www.jasonhanson.com/360flex
  • 52. Application State • Presenter currentState property • For MXML view bind the presenter.currentState to the currentState of the view • Change state on the presenter changes state on the view • In most cases views and presenters do not modify currentState, the controller does www.jasonhanson.com/360flex
  • 54. Tip: No States as a String-Based Contracts • Bad idea in general • Typos break apps at runtime :( • Use enums or constants for state names • Spark state name property does not support constants values. Must use a string in this case. www.jasonhanson.com/360flex
  • 56. Spark States User error failure point. Strings not compile checked against enum. www.jasonhanson.com/360flex
  • 57. ViewNavigator State Translator • Mobile View-Based Applications use a ViewNavigator • Similar to a stack of cards • pushView(viewClass:Class, ....) • replaceView() • popView(), popToFirstView() • not state friendly by default www.jasonhanson.com/360flex
  • 58. ViewNavigator State Translator • ViewNavigator methods require a view class type • State is held in the ‘core’ presenters • Presenters have no knowledge of screen-specific view classes • Need to translate states to view classes www.jasonhanson.com/360flex
  • 59. ViewNavigator State Translator www.jasonhanson.com/360flex
  • 60. ViewNavigator State Translator www.jasonhanson.com/360flex
  • 61. ViewNavigator State Translator www.jasonhanson.com/360flex
  • 63. Let’s Look at Some Code • Show code • Show apps running on devices • Try not to break it www.jasonhanson.com/360flex
  • 65. Where to go From Here? • Get Flash Builder 4.5 • Check out other talks this week for more details on different parts of what I covered today • Go build something! www.jasonhanson.com/360flex
  • 66. END (almost) www.jasonhanson.com/360flex
  • 67. Advert: My Other Talk • Deep Dive into Flex Mobile Item Renderers • Wed 10:50am - 12:00pm • Snip from that preso on next slide www.jasonhanson.com/360flex
  • 70. Intentional Left Blank www.jasonhanson.com/360flex
  • 71. • Extra Slides After This Point www.jasonhanson.com/360flex