Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Supercharge your PhoneGap workflow

Eric Alli
January 29, 2016

Supercharge your PhoneGap workflow

Developing a complex and sustainable PhoneGap app can present many challenges. As your app grows, a seamless development workflow is crucial. Can you efficiently deploy and test in different environments? What are your pain points when implementing new functionality? How can you organize all the facets of your app with minimal effort? 

This talk focuses on some of the ways you can create a development workflow that automates efficiencies, boosts scalability and most of all, preserves developer sanity.

Eric Alli

January 29, 2016
Tweet

Other Decks in Programming

Transcript

  1. REFRAMING THE IDEA OF SCALING ▸ Kept me writing clean,

    maintainable code ▸ Made it conducive to document as I was coding ▸ Created an automatic, holistic workflow ▸ Increased my ability to be agile
  2. REFRAMING THE IDEA OF SCALING ▸ Kept me writing clean,

    maintainable code ▸ Made it conducive to document as I was coding ▸ Created an automatic, holistic workflow ▸ Increased my ability to be agile
  3. REFRAMING THE IDEA OF SCALING ▸ Kept me writing clean,

    maintainable code ▸ Made it conducive to document as I was coding ▸ Created an automatic, holistic workflow ▸ Increased my ability to be agile
  4. REFRAMING THE IDEA OF SCALING ▸ Kept me writing clean,

    maintainable code ▸ Made it conducive to document as I was coding ▸ Created an automatic, holistic workflow ▸ Increased my ability to be agile
  5. REFRAMING THE IDEA OF SCALING ▸ Kept me writing clean,

    maintainable code ▸ Made it conducive to document as I was coding ▸ Created an automatic, holistic workflow ▸ Increased my ability to be agile
  6. FRAMEWORKS ▸ Readily available ▸ Usually does most of what

    you need ▸ Tested and production ready ▸ Doesn’t do exactly what you need ▸ Requires separate maintenance CUSTOM CODE ▸ Gives you total control ▸ Will do exactly what you need ▸ Adaptable to your growing / changing app ▸ Requires planning and dev time ▸ Adds more to your testing workload
  7. DATA CONSIDERATIONS ▸ Consider creating a backend API that prepares

    all the data that will your app with consume ▸ API’s can range from a simple node server or a collection of PHP scripts to a full blown Ruby on Rails or Python app. ▸ Backend-as-a-Service tools are also a good alternative
  8. DATA CONSIDERATIONS ▸ Consider creating a backend API that prepares

    all the data that will your app with consume ▸ API’s can range from a simple node server or a collection of PHP scripts to a full blown Ruby on Rails or Python app. ▸ Backend-as-a-Service tools are also a good option
  9. DATA CONSIDERATIONS ▸ Consider creating a backend API that prepares

    all the data that will your app with consume ▸ API’s can range from a simple node server or a collection of PHP scripts to a full blown Ruby on Rails or Python app. ▸ Backend-as-a-Service tools are also a good option
  10. DATA CONSIDERATIONS ▸ Consider creating a backend API that prepares

    all the data that will your app with consume ▸ API’s can range from a simple node server or a collection of PHP scripts to a full blown Ruby on Rails or Python app. ▸ Backend-as-a-Service tools are also a good option
  11. AUTOMATION OPPORTUNITIES ▸ Making a list of all the tasks

    I do in every day developing. Not leaving anything out, big or small ▸ Consider if automation can be applied to each item ▸ Use a task runner (grunt or gulp) to offload some of the manual workload
  12. AUTOMATION OPPORTUNITIES ▸ Making a list of all the tasks

    I do in every day developing. Not leaving anything out, big or small ▸ Consider if automation can be applied to each item ▸ Use a task runner (grunt or gulp) to offload some of the manual workload
  13. AUTOMATION OPPORTUNITIES ▸ Making a list of all the tasks

    I do in every day developing. Not leaving anything out, big or small ▸ Consider if automation can be applied to each item ▸ Use a task runner (grunt or gulp) to offload some of the manual workload
  14. AUTOMATION OPPORTUNITIES ▸ Making a list of all the tasks

    I do in every day developing. Not leaving anything out, big or small ▸ Consider if automation can be applied to each item ▸ Use a task runner (grunt or gulp) to offload some of the manual workload
  15. IT WILL BE SO MUCH MORE WORK IN THE BEGINNING,

    BUT YOU’LL THANK YOURSELF LATER.
  16. Don’t delay device testing, bugs WILL find you in new

    and inventive ways. TEST TODAY FOR A BETTER TOMORROW
  17. THERE ARE SO MANY WAYS TO DEBUG POORLY ▸Thinking your

    app is just website ▸Thinking your app isn’t just a website ▸Missing potential device-related issues
  18. THERE ARE SO MANY WAYS TO DEBUG POORLY ▸Thinking your

    app is just website ▸Thinking your app isn’t just a website ▸Missing potential device-related issues
  19. THERE ARE SO MANY WAYS TO DEBUG POORLY ▸Thinking your

    app is just website ▸Thinking your app isn’t just a website ▸Missing potential device-related issues
  20. THERE ARE SO MANY WAYS TO DEBUG POORLY ▸Thinking your

    app is just website ▸Thinking your app isn’t just a website ▸Missing potential device-related issues
  21. THERE ARE SO MANY WAYS TO DEBUG BETTER ▸Take advantage

    of all browser-based debugging tools ▸Consider remote-device debugging tools (weinre, GapDebug) ▸Use a behavior driven (BDD) testing tool
  22. THERE ARE SO MANY WAYS TO DEBUG BETTER ▸Take advantage

    of all browser-based debugging tools ▸Consider remote-device debugging tools (weinre, GapDebug) ▸Use a behavior driven (BDD) testing tool
  23. THERE ARE SO MANY WAYS TO DEBUG BETTER ▸Take advantage

    of all browser-based debugging tools ▸Consider remote-device debugging tools (weinre, GapDebug) ▸Use a behavior driven (BDD) testing tool
  24. THERE ARE SO MANY WAYS TO DEBUG BETTER ▸Take advantage

    of all browser-based debugging tools ▸Consider remote-device debugging tools (weinre, GapDebug) ▸Use a behavior driven (BDD) testing tool
  25. As you grow, it’s harder to mentally grasp your entire

    app’s codebase. Splitting it up into manageable chunks can really help. GROWING PAINS
  26. WOULD YOU RATHER… A. Have a few files with 5k+

    lines of code each B. Have many files with a few hundred lines of code each
  27. A. Have a few files with 5k+ lines of code

    each B. Have many files with a few hundred lines of code each WOULD YOU RATHER…
  28. /*
 ______ 
 | ____| 
 | |__ ___ _

    __ _ __ ___ ___ 
 | __/ _ \| '__| '_ ` _ \/ __|
 | | | (_) | | | | | | | \__ \
 |_| \___/|_| |_| |_| |_|___/ */ form {
 position: relative;
 
 input {
 ...
 }
 }
  29. A. Have a few files with 5k+ lines of code

    each B. Have many files with a few hundred lines of code each WOULD YOU RATHER…
  30. SEGMENT EVERY PIECE OF FUNCTIONALITY INTO BITE-SIZED FILES ▸ Name

    them by screen or by a specific feature ▸ Keep naming consistent: ▸ dashboard.css ▸ dashboard.js ▸ dashboard.template
  31. MAKING THE MOST OUT OF OPEN SOURCE ▸Choosing libraries that

    are mobile-first ▸Looking out for dependency requirements ▸Finding tools that can do more than one job
  32. MAKING THE MOST OUT OF OPEN SOURCE ▸Choosing libraries that

    are mobile-first ▸Looking out for dependency requirements ▸Finding tools that can do more than one job
  33. MAKING THE MOST OUT OF OPEN SOURCE ▸Choosing libraries that

    are mobile-first ▸Looking out for dependency requirements ▸Finding tools that can do more than one job
  34. Sprinkle in some native for common UI functionality. No Swift

    of Java required* USE NATIVE FUNCTIONALITY!
  35. EVERYDAY NATIVE PLUGINS ▸ Social Sharing ▸ Maps ▸ Page

    Transitions ▸ Progress Indicators ▸ Action Sheets ▸ …
  36. EVERYDAY NATIVE PLUGINS ▸ Social Sharing ▸ Maps ▸ Page

    Transitions ▸ Progress Indicators ▸ Action Sheets ▸ …
  37. EVERYDAY NATIVE PLUGINS ▸ Social Sharing ▸ Maps ▸ Page

    Transitions ▸ Progress Indicators ▸ Action Sheets ▸ …
  38. EVERYDAY NATIVE PLUGINS ▸ Social Sharing ▸ Maps ▸ Page

    Transitions ▸ Progress Indicators ▸ Action Sheets ▸ …
  39. EVERYDAY NATIVE PLUGINS ▸ Social Sharing ▸ Maps ▸ Page

    Transitions ▸ Progress Indicators ▸ Action Sheets ▸ …
  40. EVERYDAY NATIVE PLUGINS ▸ Social Sharing ▸ Maps ▸ Page

    Transitions ▸ Progress Indicators ▸ Action Sheets ▸ …
  41. WITH EVERY BIT OF NATIVE FUNCTIONALITY YOU INCLUDE IN YOUR

    APP… IT’S AN OPPORTUNITY TO OFFER A MORE FAMILIAR EXPERIENCE FOR THE USER.
  42. RECLAIM YOUR CODE Develop your app code outside of your

    PhoneGap project…don’t worry, we’ll create a slick build process to reunite everything later.
  43. Move all app-specific code living in the www/ folder of

    your PhoneGap project to a folder outside of the project.
  44. Use a task runner to copy only the files you

    need into PhoneGap when the time comes. KEEPS YOUR CODE SEPARATE
  45. INSTALLING GRUNT ▸ Install Node.js from nodejs.org ▸ Initialize npm

    in your project ▸ Install Grunt ▸ Install packages
  46. INSTALLING GRUNT ▸ Install Node.js from nodejs.org ▸ Initialize npm

    in your project ▸ Install Grunt ▸ Install packages $ > npm init

  47. INSTALLING GRUNT ▸ Install Node.js from nodejs.org ▸ Initialize npm

    in your project ▸ Install Grunt ▸ Install packages $ > npm init $ > npm install -g grunt-cli $ > npm install grunt —save-dev 

  48. INSTALLING GRUNT ▸ Install Node.js from nodejs.org ▸ Initialize npm

    in your project ▸ Install Grunt ▸ Install packages $ > npm init $ > npm install -g grunt-cli $ > npm install grunt —save-dev $ > npm install grunt-sass —save-dev $ > npm install load-grunt-tasks —save- 
 dev
 $ > ...
  49. EXAMPLE GRUNTFILE.JS module.exports = function(grunt) {
 
 // Load all

    packages
 require("load-grunt-tasks")(grunt, {scope: "devDependencies"}); // Project configuration
 grunt.initConfig({
 // Sass compilation
 sass: { 
 dist: { 
 files: { 
 "stylesheets/style.css": "stylesheets/style.scss"
 }
 }
 },
 });
 
 // Task groups
 grunt.registerTask('default', ['sass']);
 };
  50. {COMPILES STYLESHEETS COMPILES TEMPLATES MINIFIES JAVASCRIPTS MINIFIES HTML CLEANS AND

    COPIES WWW BUILDS THE PHONEGAP PROJECT LAUNCHES AN EMULATOR
  51. {COMPILES STYLESHEETS COMPILES TEMPLATES MINIFIES JAVASCRIPTS MINIFIES HTML CLEANS AND

    COPIES WWW BUILDS THE PHONEGAP PROJECT LAUNCHES AN EMULATOR SASS, LESS…
  52. {COMPILES STYLESHEETS COMPILES TEMPLATES MINIFIES JAVASCRIPTS MINIFIES HTML CLEANS AND

    COPIES WWW BUILDS THE PHONEGAP PROJECT LAUNCHES AN EMULATOR HANDLEBARS, MUSTACHEJS…
  53. {COMPILES STYLESHEETS COMPILES TEMPLATES MINIFIES JAVASCRIPTS MINIFIES HTML CLEANS AND

    COPIES WWW BUILDS THE PHONEGAP PROJECT LAUNCHES AN EMULATOR JSHINT & CONCATENATE
  54. {COMPILES STYLESHEETS COMPILES TEMPLATES MINIFIES JAVASCRIPTS MINIFIES HTML CLEANS AND

    COPIES WWW BUILDS THE PHONEGAP PROJECT LAUNCHES AN EMULATOR index.html
  55. {COMPILES STYLESHEETS COMPILES TEMPLATES MINIFIES JAVASCRIPTS MINIFIES HTML CLEANS AND

    COPIES WWW BUILDS THE PHONEGAP PROJECT LAUNCHES AN EMULATOR COPY TO XCODE PROJECT
  56. {COMPILES STYLESHEETS COMPILES TEMPLATES MINIFIES JAVASCRIPTS MINIFIES HTML CLEANS AND

    COPIES WWW BUILDS THE PHONEGAP PROJECT LAUNCHES AN EMULATOR phonegap build
  57. {COMPILES STYLESHEETS COMPILES TEMPLATES MINIFIES JAVASCRIPTS MINIFIES HTML CLEANS AND

    COPIES WWW BUILDS THE PHONEGAP PROJECT LAUNCHES AN EMULATOR phonegap emulate
  58. EVEN MORE BUILD TASKS ▸ Watch files for changes and

    run relevant tasks ▸ Preprocess the index.html file (for different environments / platforms) ▸ Optimize images ▸ Run virtually any shell commands
  59. EVEN MORE BUILD TASKS ▸ Watch files for changes and

    run relevant tasks ▸ Preprocess the index.html file (for different environments / platforms) ▸ Optimize images ▸ Run virtually any shell commands
  60. EVEN MORE BUILD TASKS ▸ Watch files for changes and

    run relevant tasks ▸ Preprocess the index.html file (for different environments / platforms) ▸ Optimize images ▸ Run virtually any shell commands
  61. EVEN MORE BUILD TASKS ▸ Watch files for changes and

    run relevant tasks ▸ Preprocess the index.html file (for different environments / platforms) ▸ Optimize images ▸ Run virtually any shell commands
  62. EVEN MORE BUILD TASKS ▸ Watch files for changes and

    run relevant tasks ▸ Preprocess the index.html file (for different environments / platforms) ▸ Optimize images ▸ Run virtually any shell commands
  63. YOU ARE YOUR OWN BOTTLENECK ▸ Empower yourself to make

    quick and clear development decisions ▸ Organize today to help you scale for tomorrow ▸ Give yourself confidence to launch your app when the time comes ▸ Create efficiencies for yourself, then automate them
  64. YOU ARE YOUR OWN BOTTLENECK ▸ Empower yourself to make

    quick and clear development decisions ▸ Organize today to help you scale for tomorrow ▸ Give yourself confidence to launch your app when the time comes ▸ Create efficiencies for yourself, then automate them
  65. YOU ARE YOUR OWN BOTTLENECK ▸ Empower yourself to make

    quick and clear development decisions ▸ Organize today to help you scale for tomorrow ▸ Give yourself confidence to launch your app when the time comes ▸ Create efficiencies for yourself, then automate them
  66. YOU ARE YOUR OWN BOTTLENECK ▸ Empower yourself to make

    quick and clear development decisions ▸ Organize today to help you scale for tomorrow ▸ Give yourself confidence to launch your app when the time comes ▸ Create efficiencies for yourself, then automate them
  67. YOU ARE YOUR OWN BOTTLENECK ▸ Empower yourself to make

    quick and clear development decisions ▸ Organize today to help you scale for tomorrow ▸ Give yourself confidence to launch your app when the time comes ▸ Create efficiencies for yourself, then automate them