SlideShare ist ein Scribd-Unternehmen logo
1 von 37
Downloaden Sie, um offline zu lesen
ME: SEAN VOISEN
               THIS: SYNC IT UP
               Synchronizing Desktop Data with AIR and SQLite
               @ FITC, Toronto on April 21, 2008




Sean Voisen 2008.
Licensed under Creative Commons Attribution No-Derivatives 3.0 license.
A FEW ASSUMPTIONS ...


•YOU KNOW SOME AS3
•YOU’VE TRIED AIR DEVELOPMENT
•YOU KNOW A LITTLE SQL
1. WHY SYNCHRONIZE?

                    2. SYNCHRONIZATION STRATEGIES.

                    3. DESIGN PATTERNS.

                    4. SQLITE IN AIR.

                    5. CONNECTION DETECTION IN AIR.

                    6. AS3 PROGRAMMING STRATEGIES.


Sean Voisen 2008.
Licensed under Creative Commons Attribution No-Derivatives 3.0 license.
WHY SYNCHRONIZE?
               When it’s not always good to have your head in the
               “cloud.”




Sean Voisen 2008.
Licensed under Creative Commons Attribution No-Derivatives 3.0 license.
•OFFLINE DATA ACCESS
                    •LARGE DATA SETS
                    •FASTER START UP TIME
                    •STORE EPHEMERAL DATA
                    •EXPORT DATA EASILY

Sean Voisen 2008.
Licensed under Creative Commons Attribution No-Derivatives 3.0 license.
SYNCHRONIZATION
               STRATEGIES.
               Keeping your data fresh.




Sean Voisen 2008.
Licensed under Creative Commons Attribution No-Derivatives 3.0 license.
•USER MAKES CHANGES WHILE OFFLINE
                    •DATA IS CHANGED ON SERVER BY THIRD
                           PARTIES

                    •DATA IS CHANGED LOCALLY BY THIRD
                           PARTIES (RSS FEEDS)



Sean Voisen 2008.
Licensed under Creative Commons Attribution No-Derivatives 3.0 license.
MANUAL SYNC

                    •REQUIRES USER TO PUSH A BUTTON
                    •GOOD FOR SHORT SYNC TIMES OR
                           SMALL AMOUNTS OF DATA

                    •EASIEST TO IMPLEMENT
                    •BUT ... USER MAY FORGET
Sean Voisen 2008.
Licensed under Creative Commons Attribution No-Derivatives 3.0 license.
BACKGROUND SYNC

                    •WORKS “BEHIND THE SCENES”
                           WITHOUT INTERVENTION

                    •USE TIMER OR TRIGGERING EVENTS
                           (PROBABLY BOTH)

                    •SERVER CAN PUSH DATA (LIVECYCLE
                           DATA SERVICES)


Sean Voisen 2008.
Licensed under Creative Commons Attribution No-Derivatives 3.0 license.
WHAT TO SYNC

                    •TIMESTAMPS
                    •“DIRTY” BITS
                    •DIRECT DATA COMPARISON
                    •COLLISIONS: CLIENT OVERRIDES
                           SERVER, SERVER OVERRIDES CLIENT


Sean Voisen 2008.
Licensed under Creative Commons Attribution No-Derivatives 3.0 license.
DESIGN PATTERNS
               Make it beautiful and usable.




Sean Voisen 2008.
Licensed under Creative Commons Attribution No-Derivatives 3.0 license.
•PATTERN: AN APPROPRIATE AND
                           SUCCESSFUL APPROACH TO A
                           PROBLEM.




Sean Voisen 2008.
Licensed under Creative Commons Attribution No-Derivatives 3.0 license.
BRETT RAMPATA
•ACCOMODATES BOTH MANUAL
 AND BACKGROUND
 SYNCHRONIZATION

•UNOBTRUSIVE
•CONNECTION AVAILABILITY
 AND SYNC ARE VISUALLY LINKED
DEMO: PAYPAL DESKTOP.
A combined project of Adobe XD and PayPal, with a
little help from yours truly.
SQLite in AIR.
               What you need to know to
               get your feet wet.




Sean Voisen 2008.
Licensed under Creative Commons Attribution No-Derivatives 3.0 license.
•EMBEDDED SQL DATABASE ENGINE
                    •NO SETUP, NO SERVER
                    •DATABASE IS STORED AS A SINGLE FILE
                    •MOST OF SQL92 SUPPORTED
                         • INCLUDING THE ADVANCED STUFF LIKE
                                 VIEWS, TRANSACTIONS AND TRIGGERS!




Sean Voisen 2008.
Licensed under Creative Commons Attribution No-Derivatives 3.0 license.
DATA TYPES in SQLite

                    •SQLite USES TYPE AFFINITIES
                    •TYPE “AFFINITY” = RECOMMENDED,
                           BUT NOT REQUIRED

                    •THE NORMAL SQLite AFFINITIES:
                         • NULL, INTEGER, REAL, TEXT, BLOB

Sean Voisen 2008.
Licensed under Creative Commons Attribution No-Derivatives 3.0 license.
•ADDITIONAL TYPE AFFINITIES
                           AVAILABLE FOR AIR:
                         • TEXT, NUMERIC, INTEGER, REAL, BOOLEAN,
                                 DATE, XML, XMLList, OBJECT, NONE




Sean Voisen 2008.
Licensed under Creative Commons Attribution No-Derivatives 3.0 license.
THE BASICS
                    1. CREATE A File REFERENCE FOR THE DB
                    2. CREATE A SQLConnection INSTANCE
                    3. OPEN SQLConnection ON FILE
                    4. CREATE A QUERY USING
                       SQLStatement
                    5. EXECUTE THE QUERY

Sean Voisen 2008.
Licensed under Creative Commons Attribution No-Derivatives 3.0 license.
var db:File = File.applicationStorageDirectory.resolvePath(
   "filename.db");
var connection:SQLConnection = new SQLConnection();
connection.openAsync(db, SQLMode.CREATE);

var stmt:SQLStatement = new SQLStatement();
stmt.sqlConnection = connection;
stmt.text = "SELECT * FROM mytable";
stmt.addEventListener( SQLEvent.RESULT, onResult );
stmt.execute();
•SQLConnection SUPPORTS BOTH
                           SYNCHRONOUS AND ASYNCHRONOUS
                           CONNECTIONS

                         • SYNC: APP INTERACTIVITY BLOCKED UNTIL
                                 COMPLETE (LIKE FILE I/O API)

                         • ASYNC: USES EVENT LISTENERS AND
                                 QUERIES ARE QUEUED




Sean Voisen 2008.
Licensed under Creative Commons Attribution No-Derivatives 3.0 license.
ABOUT PARAMETERS
                           var stmt:SQLStatement = new SQLStatement();
                           stmt.text = "SELECT * FROM mytable WHERE id = :id";
                           stmt.parameters[":id"] = 5;
                           stmt.execute();




                    •CACHES QUERY FOR FASTER
                           EXECUTION

                    •PREVENTS INJECTION VULNERABILITY
Sean Voisen 2008.
Licensed under Creative Commons Attribution No-Derivatives 3.0 license.
ABOUT RESULT PAGING

                    •SQLStatement SUPPORTS PAGING
                    •LIMITS NUMBER OF ROWS RETURNED
                           var statement:SQLStatement = new SQLStatement();
                           statement.sqlConnection = mySQLConnection;
                           statement.text = "SELECT * FROM contacts";
                           statement.execute( 10 );

                           statement.next();




Sean Voisen 2008.
Licensed under Creative Commons Attribution No-Derivatives 3.0 license.
ABOUT TRANSACTIONS
                    •MULTIPLE STATEMENTS (USING
                           LOOPS) IN ONE WRITE OPERATION

                    •ALLOWS ROLLBACKS ON ERROR
                           var stmt:SQLStatement = new SQLStatement();
                           stmt.sqlConnection = connection;
                           stmt.text = "INSERT INTO tasks VALUES(:task)";
                           connection.begin();
                           for each( var task:String in tasks ) {
                              stmt.parameters[":task"] = task;
                              stmt.execute();
                           }
                           connection.commit();



Sean Voisen 2008.
Licensed under Creative Commons Attribution No-Derivatives 3.0 license.
CONNECTION
               DETECTION
               in AIR.
               Is this thing on?




Sean Voisen 2008.
Licensed under Creative Commons Attribution No-Derivatives 3.0 license.
•NATIVE      NativeApplication.nativeApplication.addEventListener(
                                 Event.NETWORK_CHANGE, onNetworkChange );


                         • ONLY DETECTS A CHANGE!
                    •SERVICE MONITOR FRAMEWORK
                         • URLMonitor
                                 var m:URLMonitor = new URLMonitor(
                                    new URLRequest('http://myurl.com') );
                                 m.addEventListener( StatusEvent.STATUS, onStatus );
                                 m.start();


                         • SocketMonitor
Sean Voisen 2008.
Licensed under Creative Commons Attribution No-Derivatives 3.0 license.
AS3 PROGRAMMING
               STRATEGIES
               A few tips to make your life easier.




Sean Voisen 2008.
Licensed under Creative Commons Attribution No-Derivatives 3.0 license.
CREATE DAOs
                    •DAO = DATA ACCESS OBJECT
                    •SINGLETON or STATIC CLASS
                    •ABSTRACTS SQL MANIPULATION,
                           HANDLES CRUD OPERATIONS

                    •ONE PLACE FOR DB ACCESS and
                           HANDLING DB ERRORS

Sean Voisen 2008.
Licensed under Creative Commons Attribution No-Derivatives 3.0 license.
public class ContactsDAO {
   private static var instance:ContactsDAO;
   public function ContactsDAO() {
      if( ContactsDAO.instance != null ) {
         throw new Error("Singleton!");
      }
   }

    public static function getInstance():ContactsDAO {
       if( ContactsDAO.instance == null ) {
          ContactsDAO.instance = new ContactsDAO();
       }
       return ContactsDAO.instance;
    }

    public function getAllContacts( resultHandler:Function,
    faultHandler:Function ):void {
	      var statement:SQLStatement = new SQLStatement();
	      statement.sqlConnection = mySQLConnection;
	      statement.text = "SELECT * FROM contacts";
	      statement.execute( -1, new Responder(
          function( result:SQLResult ):void {
             resultHandler.call( this, result.data );
          }, faultHandler )
       );
    }
}
USE “IF NOT EXISTS”

                    •CREATE TABLES WHEN DB IS OPENED
                           IF THEY DON’T EXIST
                           var statement:SQLStatement = new SQLStatement();
                           statement.sqlConnection = mySQLConnection;
                           statement.text = "CREATE TABLE IF NOT EXISTS mytable (" +
                              "id INTEGER PRIMARY KEY AUTOINCREMENT," +
                              "first_name TEXT," +
                              "last_name TEXT)";
                           statement.addEventListener( SQLEvent.RESULT, onResult );
                           statement.execute();




Sean Voisen 2008.
Licensed under Creative Commons Attribution No-Derivatives 3.0 license.
WATCH FOR MEMORY
               LEAKS
                •DATA QUERIED FROM SQL STORED IN
                           Array/ArrayCollection
                         • DATA CAN’T BE USED DIRECTLY FROM DB IN
                                 GRIDS, CHARTS, ETC.

                         • RELOAD ALL DATA IN ARRAYS? OR
                                 INDIVIDUAL ITEMS?

                    •USE FLEX 3 PROFILER
Sean Voisen 2008.
Licensed under Creative Commons Attribution No-Derivatives 3.0 license.
DEMO: Librarian
Free sample code to be posted on voisen.org
USE SQLiteAdmin

                    •USED TO HANDY TOOLS LIKE
                           PHPMyAdmin? Try:
                                 http://coenraets.org/blog/2008/02/
                                 sqlite-admin-for-air-10/



Sean Voisen 2008.
Licensed under Creative Commons Attribution No-Derivatives 3.0 license.
DEMO: SQLite Admin.
By Christophe Coenraets.
RESOURCES
                    •CHRISTOPHE COENRAETS: coenraets.org -
                           SQLite Admin for AIR

                    •PETER ELST: peterelst.com - SQLite
                           Wrapper Classes

                    •PAUL ROBERTSON: probertson.com -
                           Insider info on AIR SQLite

                    •ADOBE XD: xd.adobe.com
Sean Voisen 2008.
Licensed under Creative Commons Attribution No-Derivatives 3.0 license.
QUESTIONS?
               Web: http://voisen.org
               E-mail: sean@voisen.org




Sean Voisen 2008.
Licensed under Creative Commons Attribution No-Derivatives 3.0 license.

Weitere ähnliche Inhalte

Ähnlich wie Sync It Up

Don't Drop the SOAP: Real World Web Service Testing for Web Hackers
Don't Drop the SOAP: Real World Web Service Testing for Web Hackers Don't Drop the SOAP: Real World Web Service Testing for Web Hackers
Don't Drop the SOAP: Real World Web Service Testing for Web Hackers Tom Eston
 
OpenStack Technology Overview
OpenStack Technology OverviewOpenStack Technology Overview
OpenStack Technology OverviewOpen Stack
 
AWS re:Invent 2016: Amazon CloudFront Flash Talks: Best Practices on Configur...
AWS re:Invent 2016: Amazon CloudFront Flash Talks: Best Practices on Configur...AWS re:Invent 2016: Amazon CloudFront Flash Talks: Best Practices on Configur...
AWS re:Invent 2016: Amazon CloudFront Flash Talks: Best Practices on Configur...Amazon Web Services
 
Enterprise Node - Securing Your Environment
Enterprise Node - Securing Your EnvironmentEnterprise Node - Securing Your Environment
Enterprise Node - Securing Your EnvironmentKurtis Kemple
 
NoSQL - No Security?
NoSQL - No Security?NoSQL - No Security?
NoSQL - No Security?Gavin Holt
 
Securing Servers in Public and Hybrid Clouds
Securing Servers in Public and Hybrid CloudsSecuring Servers in Public and Hybrid Clouds
Securing Servers in Public and Hybrid CloudsRightScale
 
(DVO312) Sony: Building At-Scale Services with AWS Elastic Beanstalk
(DVO312) Sony: Building At-Scale Services with AWS Elastic Beanstalk(DVO312) Sony: Building At-Scale Services with AWS Elastic Beanstalk
(DVO312) Sony: Building At-Scale Services with AWS Elastic BeanstalkAmazon Web Services
 
Introduction to AWS Organizations
Introduction to AWS OrganizationsIntroduction to AWS Organizations
Introduction to AWS OrganizationsAmazon Web Services
 
You Too Can Be a Radio Host Or How We Scaled a .NET Startup And Had Fun Doing It
You Too Can Be a Radio Host Or How We Scaled a .NET Startup And Had Fun Doing ItYou Too Can Be a Radio Host Or How We Scaled a .NET Startup And Had Fun Doing It
You Too Can Be a Radio Host Or How We Scaled a .NET Startup And Had Fun Doing ItAleksandr Yampolskiy
 
Simple Principles for Website Security
Simple Principles for Website SecuritySimple Principles for Website Security
Simple Principles for Website SecurityLauren Wood
 
Secure Keystone Deployment
Secure Keystone DeploymentSecure Keystone Deployment
Secure Keystone DeploymentPriti Desai
 
OAuth with AngularJS and WebAPI - SoCal Code Camp 2015
OAuth with AngularJS and WebAPI - SoCal Code Camp 2015OAuth with AngularJS and WebAPI - SoCal Code Camp 2015
OAuth with AngularJS and WebAPI - SoCal Code Camp 2015Stuart
 
Hack-Proof Your Cloud: Responding to 2016 Threats
Hack-Proof Your Cloud: Responding to 2016 ThreatsHack-Proof Your Cloud: Responding to 2016 Threats
Hack-Proof Your Cloud: Responding to 2016 ThreatsAmazon Web Services
 
vlavrynovych - WebSockets Presentation
vlavrynovych - WebSockets Presentationvlavrynovych - WebSockets Presentation
vlavrynovych - WebSockets PresentationVolodymyr Lavrynovych
 
React Fast by Processing Streaming Data - AWS Summit Tel Aviv 2017
React Fast by Processing Streaming Data - AWS Summit Tel Aviv 2017React Fast by Processing Streaming Data - AWS Summit Tel Aviv 2017
React Fast by Processing Streaming Data - AWS Summit Tel Aviv 2017Amazon Web Services
 
Hack proof your aws cloud cloudcheckr_040416
Hack proof your aws cloud cloudcheckr_040416Hack proof your aws cloud cloudcheckr_040416
Hack proof your aws cloud cloudcheckr_040416Jarrett Plante
 
(ATS4-APP01) Tips and Tricks for a Successful Installation of Accelrys Electr...
(ATS4-APP01) Tips and Tricks for a Successful Installation of Accelrys Electr...(ATS4-APP01) Tips and Tricks for a Successful Installation of Accelrys Electr...
(ATS4-APP01) Tips and Tricks for a Successful Installation of Accelrys Electr...BIOVIA
 
Developing and deploying windows azure applications
Developing and deploying windows azure applicationsDeveloping and deploying windows azure applications
Developing and deploying windows azure applicationsManish Corriea
 

Ähnlich wie Sync It Up (20)

Don't Drop the SOAP: Real World Web Service Testing for Web Hackers
Don't Drop the SOAP: Real World Web Service Testing for Web Hackers Don't Drop the SOAP: Real World Web Service Testing for Web Hackers
Don't Drop the SOAP: Real World Web Service Testing for Web Hackers
 
Spa Secure Coding Guide
Spa Secure Coding GuideSpa Secure Coding Guide
Spa Secure Coding Guide
 
Getting Started with AWS IoT
Getting Started with AWS IoTGetting Started with AWS IoT
Getting Started with AWS IoT
 
OpenStack Technology Overview
OpenStack Technology OverviewOpenStack Technology Overview
OpenStack Technology Overview
 
AWS re:Invent 2016: Amazon CloudFront Flash Talks: Best Practices on Configur...
AWS re:Invent 2016: Amazon CloudFront Flash Talks: Best Practices on Configur...AWS re:Invent 2016: Amazon CloudFront Flash Talks: Best Practices on Configur...
AWS re:Invent 2016: Amazon CloudFront Flash Talks: Best Practices on Configur...
 
Enterprise Node - Securing Your Environment
Enterprise Node - Securing Your EnvironmentEnterprise Node - Securing Your Environment
Enterprise Node - Securing Your Environment
 
NoSQL - No Security?
NoSQL - No Security?NoSQL - No Security?
NoSQL - No Security?
 
Securing Servers in Public and Hybrid Clouds
Securing Servers in Public and Hybrid CloudsSecuring Servers in Public and Hybrid Clouds
Securing Servers in Public and Hybrid Clouds
 
(DVO312) Sony: Building At-Scale Services with AWS Elastic Beanstalk
(DVO312) Sony: Building At-Scale Services with AWS Elastic Beanstalk(DVO312) Sony: Building At-Scale Services with AWS Elastic Beanstalk
(DVO312) Sony: Building At-Scale Services with AWS Elastic Beanstalk
 
Introduction to AWS Organizations
Introduction to AWS OrganizationsIntroduction to AWS Organizations
Introduction to AWS Organizations
 
You Too Can Be a Radio Host Or How We Scaled a .NET Startup And Had Fun Doing It
You Too Can Be a Radio Host Or How We Scaled a .NET Startup And Had Fun Doing ItYou Too Can Be a Radio Host Or How We Scaled a .NET Startup And Had Fun Doing It
You Too Can Be a Radio Host Or How We Scaled a .NET Startup And Had Fun Doing It
 
Simple Principles for Website Security
Simple Principles for Website SecuritySimple Principles for Website Security
Simple Principles for Website Security
 
Secure Keystone Deployment
Secure Keystone DeploymentSecure Keystone Deployment
Secure Keystone Deployment
 
OAuth with AngularJS and WebAPI - SoCal Code Camp 2015
OAuth with AngularJS and WebAPI - SoCal Code Camp 2015OAuth with AngularJS and WebAPI - SoCal Code Camp 2015
OAuth with AngularJS and WebAPI - SoCal Code Camp 2015
 
Hack-Proof Your Cloud: Responding to 2016 Threats
Hack-Proof Your Cloud: Responding to 2016 ThreatsHack-Proof Your Cloud: Responding to 2016 Threats
Hack-Proof Your Cloud: Responding to 2016 Threats
 
vlavrynovych - WebSockets Presentation
vlavrynovych - WebSockets Presentationvlavrynovych - WebSockets Presentation
vlavrynovych - WebSockets Presentation
 
React Fast by Processing Streaming Data - AWS Summit Tel Aviv 2017
React Fast by Processing Streaming Data - AWS Summit Tel Aviv 2017React Fast by Processing Streaming Data - AWS Summit Tel Aviv 2017
React Fast by Processing Streaming Data - AWS Summit Tel Aviv 2017
 
Hack proof your aws cloud cloudcheckr_040416
Hack proof your aws cloud cloudcheckr_040416Hack proof your aws cloud cloudcheckr_040416
Hack proof your aws cloud cloudcheckr_040416
 
(ATS4-APP01) Tips and Tricks for a Successful Installation of Accelrys Electr...
(ATS4-APP01) Tips and Tricks for a Successful Installation of Accelrys Electr...(ATS4-APP01) Tips and Tricks for a Successful Installation of Accelrys Electr...
(ATS4-APP01) Tips and Tricks for a Successful Installation of Accelrys Electr...
 
Developing and deploying windows azure applications
Developing and deploying windows azure applicationsDeveloping and deploying windows azure applications
Developing and deploying windows azure applications
 

Kürzlich hochgeladen

SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
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
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
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
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
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
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 

Kürzlich hochgeladen (20)

SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
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!
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
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
 
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
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
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
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 

Sync It Up

  • 1. ME: SEAN VOISEN THIS: SYNC IT UP Synchronizing Desktop Data with AIR and SQLite @ FITC, Toronto on April 21, 2008 Sean Voisen 2008. Licensed under Creative Commons Attribution No-Derivatives 3.0 license.
  • 2. A FEW ASSUMPTIONS ... •YOU KNOW SOME AS3 •YOU’VE TRIED AIR DEVELOPMENT •YOU KNOW A LITTLE SQL
  • 3. 1. WHY SYNCHRONIZE? 2. SYNCHRONIZATION STRATEGIES. 3. DESIGN PATTERNS. 4. SQLITE IN AIR. 5. CONNECTION DETECTION IN AIR. 6. AS3 PROGRAMMING STRATEGIES. Sean Voisen 2008. Licensed under Creative Commons Attribution No-Derivatives 3.0 license.
  • 4. WHY SYNCHRONIZE? When it’s not always good to have your head in the “cloud.” Sean Voisen 2008. Licensed under Creative Commons Attribution No-Derivatives 3.0 license.
  • 5. •OFFLINE DATA ACCESS •LARGE DATA SETS •FASTER START UP TIME •STORE EPHEMERAL DATA •EXPORT DATA EASILY Sean Voisen 2008. Licensed under Creative Commons Attribution No-Derivatives 3.0 license.
  • 6. SYNCHRONIZATION STRATEGIES. Keeping your data fresh. Sean Voisen 2008. Licensed under Creative Commons Attribution No-Derivatives 3.0 license.
  • 7. •USER MAKES CHANGES WHILE OFFLINE •DATA IS CHANGED ON SERVER BY THIRD PARTIES •DATA IS CHANGED LOCALLY BY THIRD PARTIES (RSS FEEDS) Sean Voisen 2008. Licensed under Creative Commons Attribution No-Derivatives 3.0 license.
  • 8. MANUAL SYNC •REQUIRES USER TO PUSH A BUTTON •GOOD FOR SHORT SYNC TIMES OR SMALL AMOUNTS OF DATA •EASIEST TO IMPLEMENT •BUT ... USER MAY FORGET Sean Voisen 2008. Licensed under Creative Commons Attribution No-Derivatives 3.0 license.
  • 9. BACKGROUND SYNC •WORKS “BEHIND THE SCENES” WITHOUT INTERVENTION •USE TIMER OR TRIGGERING EVENTS (PROBABLY BOTH) •SERVER CAN PUSH DATA (LIVECYCLE DATA SERVICES) Sean Voisen 2008. Licensed under Creative Commons Attribution No-Derivatives 3.0 license.
  • 10. WHAT TO SYNC •TIMESTAMPS •“DIRTY” BITS •DIRECT DATA COMPARISON •COLLISIONS: CLIENT OVERRIDES SERVER, SERVER OVERRIDES CLIENT Sean Voisen 2008. Licensed under Creative Commons Attribution No-Derivatives 3.0 license.
  • 11. DESIGN PATTERNS Make it beautiful and usable. Sean Voisen 2008. Licensed under Creative Commons Attribution No-Derivatives 3.0 license.
  • 12. •PATTERN: AN APPROPRIATE AND SUCCESSFUL APPROACH TO A PROBLEM. Sean Voisen 2008. Licensed under Creative Commons Attribution No-Derivatives 3.0 license.
  • 14. •ACCOMODATES BOTH MANUAL AND BACKGROUND SYNCHRONIZATION •UNOBTRUSIVE •CONNECTION AVAILABILITY AND SYNC ARE VISUALLY LINKED
  • 15. DEMO: PAYPAL DESKTOP. A combined project of Adobe XD and PayPal, with a little help from yours truly.
  • 16. SQLite in AIR. What you need to know to get your feet wet. Sean Voisen 2008. Licensed under Creative Commons Attribution No-Derivatives 3.0 license.
  • 17. •EMBEDDED SQL DATABASE ENGINE •NO SETUP, NO SERVER •DATABASE IS STORED AS A SINGLE FILE •MOST OF SQL92 SUPPORTED • INCLUDING THE ADVANCED STUFF LIKE VIEWS, TRANSACTIONS AND TRIGGERS! Sean Voisen 2008. Licensed under Creative Commons Attribution No-Derivatives 3.0 license.
  • 18. DATA TYPES in SQLite •SQLite USES TYPE AFFINITIES •TYPE “AFFINITY” = RECOMMENDED, BUT NOT REQUIRED •THE NORMAL SQLite AFFINITIES: • NULL, INTEGER, REAL, TEXT, BLOB Sean Voisen 2008. Licensed under Creative Commons Attribution No-Derivatives 3.0 license.
  • 19. •ADDITIONAL TYPE AFFINITIES AVAILABLE FOR AIR: • TEXT, NUMERIC, INTEGER, REAL, BOOLEAN, DATE, XML, XMLList, OBJECT, NONE Sean Voisen 2008. Licensed under Creative Commons Attribution No-Derivatives 3.0 license.
  • 20. THE BASICS 1. CREATE A File REFERENCE FOR THE DB 2. CREATE A SQLConnection INSTANCE 3. OPEN SQLConnection ON FILE 4. CREATE A QUERY USING SQLStatement 5. EXECUTE THE QUERY Sean Voisen 2008. Licensed under Creative Commons Attribution No-Derivatives 3.0 license.
  • 21. var db:File = File.applicationStorageDirectory.resolvePath( "filename.db"); var connection:SQLConnection = new SQLConnection(); connection.openAsync(db, SQLMode.CREATE); var stmt:SQLStatement = new SQLStatement(); stmt.sqlConnection = connection; stmt.text = "SELECT * FROM mytable"; stmt.addEventListener( SQLEvent.RESULT, onResult ); stmt.execute();
  • 22. •SQLConnection SUPPORTS BOTH SYNCHRONOUS AND ASYNCHRONOUS CONNECTIONS • SYNC: APP INTERACTIVITY BLOCKED UNTIL COMPLETE (LIKE FILE I/O API) • ASYNC: USES EVENT LISTENERS AND QUERIES ARE QUEUED Sean Voisen 2008. Licensed under Creative Commons Attribution No-Derivatives 3.0 license.
  • 23. ABOUT PARAMETERS var stmt:SQLStatement = new SQLStatement(); stmt.text = "SELECT * FROM mytable WHERE id = :id"; stmt.parameters[":id"] = 5; stmt.execute(); •CACHES QUERY FOR FASTER EXECUTION •PREVENTS INJECTION VULNERABILITY Sean Voisen 2008. Licensed under Creative Commons Attribution No-Derivatives 3.0 license.
  • 24. ABOUT RESULT PAGING •SQLStatement SUPPORTS PAGING •LIMITS NUMBER OF ROWS RETURNED var statement:SQLStatement = new SQLStatement(); statement.sqlConnection = mySQLConnection; statement.text = "SELECT * FROM contacts"; statement.execute( 10 ); statement.next(); Sean Voisen 2008. Licensed under Creative Commons Attribution No-Derivatives 3.0 license.
  • 25. ABOUT TRANSACTIONS •MULTIPLE STATEMENTS (USING LOOPS) IN ONE WRITE OPERATION •ALLOWS ROLLBACKS ON ERROR var stmt:SQLStatement = new SQLStatement(); stmt.sqlConnection = connection; stmt.text = "INSERT INTO tasks VALUES(:task)"; connection.begin(); for each( var task:String in tasks ) { stmt.parameters[":task"] = task; stmt.execute(); } connection.commit(); Sean Voisen 2008. Licensed under Creative Commons Attribution No-Derivatives 3.0 license.
  • 26. CONNECTION DETECTION in AIR. Is this thing on? Sean Voisen 2008. Licensed under Creative Commons Attribution No-Derivatives 3.0 license.
  • 27. •NATIVE NativeApplication.nativeApplication.addEventListener( Event.NETWORK_CHANGE, onNetworkChange ); • ONLY DETECTS A CHANGE! •SERVICE MONITOR FRAMEWORK • URLMonitor var m:URLMonitor = new URLMonitor( new URLRequest('http://myurl.com') ); m.addEventListener( StatusEvent.STATUS, onStatus ); m.start(); • SocketMonitor Sean Voisen 2008. Licensed under Creative Commons Attribution No-Derivatives 3.0 license.
  • 28. AS3 PROGRAMMING STRATEGIES A few tips to make your life easier. Sean Voisen 2008. Licensed under Creative Commons Attribution No-Derivatives 3.0 license.
  • 29. CREATE DAOs •DAO = DATA ACCESS OBJECT •SINGLETON or STATIC CLASS •ABSTRACTS SQL MANIPULATION, HANDLES CRUD OPERATIONS •ONE PLACE FOR DB ACCESS and HANDLING DB ERRORS Sean Voisen 2008. Licensed under Creative Commons Attribution No-Derivatives 3.0 license.
  • 30. public class ContactsDAO { private static var instance:ContactsDAO; public function ContactsDAO() { if( ContactsDAO.instance != null ) { throw new Error("Singleton!"); } } public static function getInstance():ContactsDAO { if( ContactsDAO.instance == null ) { ContactsDAO.instance = new ContactsDAO(); } return ContactsDAO.instance; } public function getAllContacts( resultHandler:Function, faultHandler:Function ):void { var statement:SQLStatement = new SQLStatement(); statement.sqlConnection = mySQLConnection; statement.text = "SELECT * FROM contacts"; statement.execute( -1, new Responder( function( result:SQLResult ):void { resultHandler.call( this, result.data ); }, faultHandler ) ); } }
  • 31. USE “IF NOT EXISTS” •CREATE TABLES WHEN DB IS OPENED IF THEY DON’T EXIST var statement:SQLStatement = new SQLStatement(); statement.sqlConnection = mySQLConnection; statement.text = "CREATE TABLE IF NOT EXISTS mytable (" + "id INTEGER PRIMARY KEY AUTOINCREMENT," + "first_name TEXT," + "last_name TEXT)"; statement.addEventListener( SQLEvent.RESULT, onResult ); statement.execute(); Sean Voisen 2008. Licensed under Creative Commons Attribution No-Derivatives 3.0 license.
  • 32. WATCH FOR MEMORY LEAKS •DATA QUERIED FROM SQL STORED IN Array/ArrayCollection • DATA CAN’T BE USED DIRECTLY FROM DB IN GRIDS, CHARTS, ETC. • RELOAD ALL DATA IN ARRAYS? OR INDIVIDUAL ITEMS? •USE FLEX 3 PROFILER Sean Voisen 2008. Licensed under Creative Commons Attribution No-Derivatives 3.0 license.
  • 33. DEMO: Librarian Free sample code to be posted on voisen.org
  • 34. USE SQLiteAdmin •USED TO HANDY TOOLS LIKE PHPMyAdmin? Try: http://coenraets.org/blog/2008/02/ sqlite-admin-for-air-10/ Sean Voisen 2008. Licensed under Creative Commons Attribution No-Derivatives 3.0 license.
  • 35. DEMO: SQLite Admin. By Christophe Coenraets.
  • 36. RESOURCES •CHRISTOPHE COENRAETS: coenraets.org - SQLite Admin for AIR •PETER ELST: peterelst.com - SQLite Wrapper Classes •PAUL ROBERTSON: probertson.com - Insider info on AIR SQLite •ADOBE XD: xd.adobe.com Sean Voisen 2008. Licensed under Creative Commons Attribution No-Derivatives 3.0 license.
  • 37. QUESTIONS? Web: http://voisen.org E-mail: sean@voisen.org Sean Voisen 2008. Licensed under Creative Commons Attribution No-Derivatives 3.0 license.