SlideShare une entreprise Scribd logo
1  sur  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

Contenu connexe

En vedette

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
 

En vedette (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
 

Similaire à 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
 

Similaire à 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
 

Plus de 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
 

Plus de 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
 

Dernier

Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 

Dernier (20)

Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 

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