SlideShare a Scribd company logo
1 of 60
Download to read offline
Philip Poots
     @pootsbook

     Ruby Developer

     Audacio.us


3

18

3
va Sc ri pt
Ja
Structure
State
Speed
Structure Framework
State Application
Speed Javascript
Structure Framework
State Application
Speed Javascript
$.getJSON("http://example.com/?
feed=json&jsonp=?", function(data){
    $('#content').html("<a href=""
+ data[0].permalink + "">" +
data[0].title + "</a>");
    $('#Date').html(data[0].date);
    $
('#Excerpt').html(data[0].excerpt);
    $('#Excerpt').after("<a href=
"" + data[0].permalink + ""
class="more">read on &raquo;</
a>");
  });
STRUCTURE   MVC Model View Controller
            Pattern
            —1979
            Architecture
            —Separate domain logic & UI
            Server-Side MVC
            —Ruby on Rails
STRUCTURE   MVC on Server
STRUCTURE   MVC on Client
STRUCTURE   Backbone Model
 window.Todo = Backbone.Model.extend({
      defaults: {
         done: false
      },
 
      toggle: function() {
         this.save(
   
 
 
 {done: !this.get("done")}
         );
      }
    });
STRUCTURE   Backbone Model
 window.Todo = Backbone.Model.extend({
      defaults: {
         done: false
      },
 
      toggle: function() {
         this.save(
   
 
 
 {done: !this.get("done")}
         );
      }
    });
STRUCTURE   Backbone Model
 window.Todo = Backbone.Model.extend({
      defaults: {
         done: false
      },
 
      toggle: function() {
         this.save(
   
 
 
 {done: !this.get("done")}
         );
      }
    });
STRUCTURE   Backbone Collection
 window.TodoList =
 Backbone.Collection.extend({
    model: Todo,
    localStorage: new Store("todos"),
    done: function() {
      return this.filter(function(todo) 
      { return todo.get('done'); });
    },
    remaining: function() {
      return this.without.apply(
        this, this.done());
     }
   });
STRUCTURE   Backbone Collection
 window.TodoList =
 Backbone.Collection.extend({
    model: Todo,
    localStorage: new Store("todos"),
    done: function() {
      return this.filter(function(todo) 
      { return todo.get('done'); });
    },
    remaining: function() {
      return this.without.apply(
        this, this.done());
     }
   });
STRUCTURE   Backbone Collection
 window.TodoList =
 Backbone.Collection.extend({
    model: Todo,
    localStorage: new Store("todos"),
    done: function() {
      return this.filter(function(todo) 
      { return todo.get('done'); });
    },
    remaining: function() {
      return this.without.apply(
        this, this.done());
     }
   });
STRUCTURE   Backbone Collection
 window.TodoList =
 Backbone.Collection.extend({
    model: Todo,
    localStorage: new Store("todos"),
    done: function() {
      return this.filter(function(todo) 
      { return todo.get('done'); });
    },
    remaining: function() {
      return this.without.apply(
        this, this.done());
     }
   });
STRUCTURE   Backbone Collection
 window.TodoList =
 Backbone.Collection.extend({
    model: Todo,
    localStorage: new Store("todos"),
    done: function() {
      return this.filter(function(todo) 
      { return todo.get('done'); });
    },
    remaining: function() {
      return this.without.apply(
        this, this.done());
     }
   });
STRUCTURE   Backbone Collection
 window.TodoList =
 Backbone.Collection.extend({
    model: Todo,
    localStorage: new Store("todos"),
    done: function() {
      return this.filter(function(todo) 
      { return todo.get('done'); });
    },
    remaining: function() {
      return this.without.apply(
        this, this.done());
     }
   });
STRUCTURE   Backbone View
 window.TodoView = Backbone.View.extend({
     tagName: "li",
     template: $("#item-template").template(),
     events: {
       "change   .check"        : "toggleDone",
       "dblclick .todo-content" : "edit",
       "click    .todo-destroy" : "destroy",
       "keypress .todo-input"   :
 "updateOnEnter",
       "blur     .todo-input"   : "close"
     },
STRUCTURE   Backbone View
 window.TodoView = Backbone.View.extend({
     tagName: "li",
     template: $("#item-template").template(),
     events: {
       "change   .check"        : "toggleDone",
       "dblclick .todo-content" : "edit",
       "click    .todo-destroy" : "destroy",
       "keypress .todo-input"   :
 "updateOnEnter",
       "blur     .todo-input"   : "close"
     },
STRUCTURE   Backbone View
 window.TodoView = Backbone.View.extend({
     tagName: "li",
     template: $("#item-template").template(),
     events: {
       "change   .check"        : "toggleDone",
       "dblclick .todo-content" : "edit",
       "click    .todo-destroy" : "destroy",
       "keypress .todo-input"   :
 "updateOnEnter",
       "blur     .todo-input"   : "close"
     },
STRUCTURE   JS Template
 window.TodoView = Backbone.View.extend({
     tagName: "li",
     template: $("#item-template").template(),
     events: {
       "change   .check"        : "toggleDone",
       "dblclick .todo-content" : "edit",
       "click    .todo-destroy" : "destroy",
       "keypress .todo-input"   :
 "updateOnEnter",
       "blur     .todo-input"   : "close"
     },
STRUCTURE   Backbone View
 window.TodoView = Backbone.View.extend({
     tagName: "li",
     template: $("#item-template").template(),
     events: {
       "change   .check"        : "toggleDone",
       "dblclick .todo-content" : "edit",
       "click    .todo-destroy" : "destroy",
       "keypress .todo-input"   :
 "updateOnEnter",
       "blur     .todo-input"   : "close"
     },
STRUCTURE   Backbone View
 initialize: function() {
   _.bindAll(this, 'render', 'close', 'remove',
 'edit');
   this.model.bind('change', this.render);
   this.model.bind('destroy', this.remove);
 },
 render: function() {
   var element = jQuery.tmpl(this.template,
 this.model.toJSON());
   $(this.el).html(element);
   this.input = this.$(".todo-input");
   return this;
 },
STRUCTURE   Backbone View
 initialize: function() {
   _.bindAll(this, 'render', 'close', 'remove',
 'edit');
   this.model.bind('change', this.render);
   this.model.bind('destroy', this.remove);
 },
 render: function() {
   var element = jQuery.tmpl(this.template,
 this.model.toJSON());
   $(this.el).html(element);
   this.input = this.$(".todo-input");
   return this;
 },
STRUCTURE   Backbone View

 toggleDone: function() {
       this.model.toggle();
     },
STRUCTURE   Backbone Router
 var Workspace =
 Backbone.Router.extend({
 
   routes: {
      "help": "help" // #help
   },
 
   help: function() {
      ...
   }
 });
STRUCTURE   Backbone Router
 var Workspace =
 Backbone.Router.extend({
 
   routes: {
      "help": "help" // #help
   },
 
   help: function() {
      ...
   }
 });
STRUCTURE   Backbone Router
 var Workspace =
 Backbone.Router.extend({
 
   routes: {
      "help": "help" // #help
   },
 
   help: function() {
      ...
   }
 });
STRUCTURE   Clean Code
Structure Framework
State Application
Speed Javascript
S TAT E   HTTP/1.1
          “It is a…stateless protocol”
           —RFC 2616 (June 1999)
S TAT E   HTTP/1.1
          “It is a…stateless protocol”
           —RFC 2616 (June 1999)

          cookies

          sessions

          form variables

          URI parameters
S TAT E   Server Owns State




          Client     Server
S TAT E   Request GET   / HTTP/1.1




          Client         Server
S TAT E   Response HTTP/1.1   200 OK




          Client       Server
S TAT E   AJAX asynchronicity




          Client     Server
S TAT E   Infrastructure
                 Client



                 Server
S TAT E   Infrastructure
                 Client



               Web Server
S TAT E   Infrastructure
                  Client



                Web Server

            RESTful Application
S TAT E   Infrastructure
                  Client



                Web Server

            RESTful Application

                 Database
S TAT E   Infrastructure
                   Client

            JavaScript MVC App.


                Web Server

             RESTful API / App.

                 Database
S TAT E   Infrastructure
                  Client

            JavaScript MVC App.

               Local Storage




          Bo nu s!
Structure Framework
State Application
Speed Javascript
SPEED   JavaScript is Fast
        Google v8 JS engine
        —focus on optimizing speed
        It runs in the browser
        —cuts out server requests
        —spares server resources
        —instantaneous UI
SPEED   Data Transport
        JSON data only
        —no markup
SPEED   Data Transport
          JSON data only
          —no markup
{ "id": 1, 
  "first_name": "Philip", 
  "last_name": "Poots", 
  "twitter": "@pootsbook"}
   vs.
"<div id="user_1">n<dl>n<dt>Name</dt>
n<dd>Philip Poots</dd>n<dt>Twitter
handle:</dt>n<dd>@pootsbook</dd>n</dl>
n</div>"
Structure Framework
State Application
Speed Javascript
http://documentcloud.github.com/backbone/
JavaScript Web Apps




@maccman

More Related Content

What's hot

Sprout core and performance
Sprout core and performanceSprout core and performance
Sprout core and performanceYehuda Katz
 
IndexedDB - Querying and Performance
IndexedDB - Querying and PerformanceIndexedDB - Querying and Performance
IndexedDB - Querying and PerformanceParashuram N
 
Backbone.js and friends
Backbone.js and friendsBackbone.js and friends
Backbone.js and friendsGood Robot
 
Angular JS blog tutorial
Angular JS blog tutorialAngular JS blog tutorial
Angular JS blog tutorialClaude Tech
 
Ember.js - A JavaScript framework for creating ambitious web applications
Ember.js - A JavaScript framework for creating ambitious web applications  Ember.js - A JavaScript framework for creating ambitious web applications
Ember.js - A JavaScript framework for creating ambitious web applications Juliana Lucena
 
AngularJS Directives
AngularJS DirectivesAngularJS Directives
AngularJS DirectivesEyal Vardi
 
Building Single Page Apps with Backbone.js, Coffeescript and Rails 3.1
Building Single Page Apps with Backbone.js, Coffeescript and Rails 3.1Building Single Page Apps with Backbone.js, Coffeescript and Rails 3.1
Building Single Page Apps with Backbone.js, Coffeescript and Rails 3.1Vagmi Mudumbai
 
AngulrJS Overview
AngulrJS OverviewAngulrJS Overview
AngulrJS OverviewEyal Vardi
 
History of jQuery
History of jQueryHistory of jQuery
History of jQueryjeresig
 
AngularJS $Provide Service
AngularJS $Provide ServiceAngularJS $Provide Service
AngularJS $Provide ServiceEyal Vardi
 
Planbox Backbone MVC
Planbox Backbone MVCPlanbox Backbone MVC
Planbox Backbone MVCAcquisio
 
Creating the interfaces of the future with the APIs of today
Creating the interfaces of the future with the APIs of todayCreating the interfaces of the future with the APIs of today
Creating the interfaces of the future with the APIs of todaygerbille
 
A New Baseline for Front-End Devs
A New Baseline for Front-End DevsA New Baseline for Front-End Devs
A New Baseline for Front-End DevsRebecca Murphey
 
AngularJS Routing
AngularJS RoutingAngularJS Routing
AngularJS RoutingEyal Vardi
 
jQuery: Nuts, Bolts and Bling
jQuery: Nuts, Bolts and BlingjQuery: Nuts, Bolts and Bling
jQuery: Nuts, Bolts and BlingDoug Neiner
 

What's hot (20)

Sprout core and performance
Sprout core and performanceSprout core and performance
Sprout core and performance
 
IndexedDB - Querying and Performance
IndexedDB - Querying and PerformanceIndexedDB - Querying and Performance
IndexedDB - Querying and Performance
 
Backbone.js and friends
Backbone.js and friendsBackbone.js and friends
Backbone.js and friends
 
Angular JS blog tutorial
Angular JS blog tutorialAngular JS blog tutorial
Angular JS blog tutorial
 
Ember.js - A JavaScript framework for creating ambitious web applications
Ember.js - A JavaScript framework for creating ambitious web applications  Ember.js - A JavaScript framework for creating ambitious web applications
Ember.js - A JavaScript framework for creating ambitious web applications
 
jQuery: Events, Animation, Ajax
jQuery: Events, Animation, AjaxjQuery: Events, Animation, Ajax
jQuery: Events, Animation, Ajax
 
Backbone js
Backbone jsBackbone js
Backbone js
 
AngularJS Directives
AngularJS DirectivesAngularJS Directives
AngularJS Directives
 
Building Single Page Apps with Backbone.js, Coffeescript and Rails 3.1
Building Single Page Apps with Backbone.js, Coffeescript and Rails 3.1Building Single Page Apps with Backbone.js, Coffeescript and Rails 3.1
Building Single Page Apps with Backbone.js, Coffeescript and Rails 3.1
 
AngulrJS Overview
AngulrJS OverviewAngulrJS Overview
AngulrJS Overview
 
History of jQuery
History of jQueryHistory of jQuery
History of jQuery
 
AngularJS $Provide Service
AngularJS $Provide ServiceAngularJS $Provide Service
AngularJS $Provide Service
 
J query training
J query trainingJ query training
J query training
 
Planbox Backbone MVC
Planbox Backbone MVCPlanbox Backbone MVC
Planbox Backbone MVC
 
jQuery in 15 minutes
jQuery in 15 minutesjQuery in 15 minutes
jQuery in 15 minutes
 
Creating the interfaces of the future with the APIs of today
Creating the interfaces of the future with the APIs of todayCreating the interfaces of the future with the APIs of today
Creating the interfaces of the future with the APIs of today
 
jQuery Presentasion
jQuery PresentasionjQuery Presentasion
jQuery Presentasion
 
A New Baseline for Front-End Devs
A New Baseline for Front-End DevsA New Baseline for Front-End Devs
A New Baseline for Front-End Devs
 
AngularJS Routing
AngularJS RoutingAngularJS Routing
AngularJS Routing
 
jQuery: Nuts, Bolts and Bling
jQuery: Nuts, Bolts and BlingjQuery: Nuts, Bolts and Bling
jQuery: Nuts, Bolts and Bling
 

Similar to Ruby Developer Philip Poots Shares Insights on JavaScript Structure, State and Speed

Understanding backbonejs
Understanding backbonejsUnderstanding backbonejs
Understanding backbonejsNick Lee
 
Javascript first-class citizenery
Javascript first-class citizeneryJavascript first-class citizenery
Javascript first-class citizenerytoddbr
 
Jarv.us Showcase — SenchaCon 2011
Jarv.us Showcase — SenchaCon 2011Jarv.us Showcase — SenchaCon 2011
Jarv.us Showcase — SenchaCon 2011Chris Alfano
 
Aplicacoes dinamicas Rails com Backbone
Aplicacoes dinamicas Rails com BackboneAplicacoes dinamicas Rails com Backbone
Aplicacoes dinamicas Rails com BackboneRafael Felix da Silva
 
[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVCAlive Kuo
 
Javascript MVC & Backbone Tips & Tricks
Javascript MVC & Backbone Tips & TricksJavascript MVC & Backbone Tips & Tricks
Javascript MVC & Backbone Tips & TricksHjörtur Hilmarsson
 
Flask and Angular: An approach to build robust platforms
Flask and Angular:  An approach to build robust platformsFlask and Angular:  An approach to build robust platforms
Flask and Angular: An approach to build robust platformsAyush Sharma
 
Writing HTML5 Web Apps using Backbone.js and GAE
Writing HTML5 Web Apps using Backbone.js and GAEWriting HTML5 Web Apps using Backbone.js and GAE
Writing HTML5 Web Apps using Backbone.js and GAERon Reiter
 
Reactive Type-safe WebComponents
Reactive Type-safe WebComponentsReactive Type-safe WebComponents
Reactive Type-safe WebComponentsMartin Hochel
 
Big Data for each one of us
Big Data for each one of usBig Data for each one of us
Big Data for each one of usOSCON Byrum
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...Fabio Franzini
 
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)Igor Bronovskyy
 
Rich Portlet Development in uPortal
Rich Portlet Development in uPortalRich Portlet Development in uPortal
Rich Portlet Development in uPortalJennifer Bourey
 
Client-side Rendering with AngularJS
Client-side Rendering with AngularJSClient-side Rendering with AngularJS
Client-side Rendering with AngularJSDavid Lapsley
 
Building iPhone Web Apps using "classic" Domino
Building iPhone Web Apps using "classic" DominoBuilding iPhone Web Apps using "classic" Domino
Building iPhone Web Apps using "classic" DominoRob Bontekoe
 
Javascript frameworks: Backbone.js
Javascript frameworks: Backbone.jsJavascript frameworks: Backbone.js
Javascript frameworks: Backbone.jsSoós Gábor
 
Rails 6 frontend frameworks
Rails 6 frontend frameworksRails 6 frontend frameworks
Rails 6 frontend frameworksEric Guo
 

Similar to Ruby Developer Philip Poots Shares Insights on JavaScript Structure, State and Speed (20)

Understanding backbonejs
Understanding backbonejsUnderstanding backbonejs
Understanding backbonejs
 
Javascript first-class citizenery
Javascript first-class citizeneryJavascript first-class citizenery
Javascript first-class citizenery
 
Jarv.us Showcase — SenchaCon 2011
Jarv.us Showcase — SenchaCon 2011Jarv.us Showcase — SenchaCon 2011
Jarv.us Showcase — SenchaCon 2011
 
Aplicacoes dinamicas Rails com Backbone
Aplicacoes dinamicas Rails com BackboneAplicacoes dinamicas Rails com Backbone
Aplicacoes dinamicas Rails com Backbone
 
Play vs Rails
Play vs RailsPlay vs Rails
Play vs Rails
 
[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC
 
Javascript MVC & Backbone Tips & Tricks
Javascript MVC & Backbone Tips & TricksJavascript MVC & Backbone Tips & Tricks
Javascript MVC & Backbone Tips & Tricks
 
Flask and Angular: An approach to build robust platforms
Flask and Angular:  An approach to build robust platformsFlask and Angular:  An approach to build robust platforms
Flask and Angular: An approach to build robust platforms
 
Writing HTML5 Web Apps using Backbone.js and GAE
Writing HTML5 Web Apps using Backbone.js and GAEWriting HTML5 Web Apps using Backbone.js and GAE
Writing HTML5 Web Apps using Backbone.js and GAE
 
How to React Native
How to React NativeHow to React Native
How to React Native
 
Reactive Type-safe WebComponents
Reactive Type-safe WebComponentsReactive Type-safe WebComponents
Reactive Type-safe WebComponents
 
Backbone.js
Backbone.jsBackbone.js
Backbone.js
 
Big Data for each one of us
Big Data for each one of usBig Data for each one of us
Big Data for each one of us
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
 
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
 
Rich Portlet Development in uPortal
Rich Portlet Development in uPortalRich Portlet Development in uPortal
Rich Portlet Development in uPortal
 
Client-side Rendering with AngularJS
Client-side Rendering with AngularJSClient-side Rendering with AngularJS
Client-side Rendering with AngularJS
 
Building iPhone Web Apps using "classic" Domino
Building iPhone Web Apps using "classic" DominoBuilding iPhone Web Apps using "classic" Domino
Building iPhone Web Apps using "classic" Domino
 
Javascript frameworks: Backbone.js
Javascript frameworks: Backbone.jsJavascript frameworks: Backbone.js
Javascript frameworks: Backbone.js
 
Rails 6 frontend frameworks
Rails 6 frontend frameworksRails 6 frontend frameworks
Rails 6 frontend frameworks
 

Recently uploaded

Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...itnewsafrica
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesBernd Ruecker
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxfnnc6jmgwh
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...itnewsafrica
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesManik S Magar
 
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
 

Recently uploaded (20)

Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architectures
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
 
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.
 

Ruby Developer Philip Poots Shares Insights on JavaScript Structure, State and Speed

  • 1.
  • 2. Philip Poots @pootsbook Ruby Developer Audacio.us 3 18 3
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12. va Sc ri pt Ja
  • 16. $.getJSON("http://example.com/? feed=json&jsonp=?", function(data){ $('#content').html("<a href="" + data[0].permalink + "">" + data[0].title + "</a>"); $('#Date').html(data[0].date); $ ('#Excerpt').html(data[0].excerpt); $('#Excerpt').after("<a href= "" + data[0].permalink + "" class="more">read on &raquo;</ a>"); });
  • 17. STRUCTURE MVC Model View Controller Pattern —1979 Architecture —Separate domain logic & UI Server-Side MVC —Ruby on Rails
  • 18. STRUCTURE MVC on Server
  • 19. STRUCTURE MVC on Client
  • 20. STRUCTURE Backbone Model window.Todo = Backbone.Model.extend({ defaults: { done: false }, toggle: function() { this.save( {done: !this.get("done")} ); } });
  • 21. STRUCTURE Backbone Model window.Todo = Backbone.Model.extend({ defaults: { done: false }, toggle: function() { this.save( {done: !this.get("done")} ); } });
  • 22. STRUCTURE Backbone Model window.Todo = Backbone.Model.extend({ defaults: { done: false }, toggle: function() { this.save( {done: !this.get("done")} ); } });
  • 23. STRUCTURE Backbone Collection window.TodoList = Backbone.Collection.extend({ model: Todo, localStorage: new Store("todos"), done: function() { return this.filter(function(todo) { return todo.get('done'); }); }, remaining: function() { return this.without.apply( this, this.done()); } });
  • 24. STRUCTURE Backbone Collection window.TodoList = Backbone.Collection.extend({ model: Todo, localStorage: new Store("todos"), done: function() { return this.filter(function(todo) { return todo.get('done'); }); }, remaining: function() { return this.without.apply( this, this.done()); } });
  • 25. STRUCTURE Backbone Collection window.TodoList = Backbone.Collection.extend({ model: Todo, localStorage: new Store("todos"), done: function() { return this.filter(function(todo) { return todo.get('done'); }); }, remaining: function() { return this.without.apply( this, this.done()); } });
  • 26. STRUCTURE Backbone Collection window.TodoList = Backbone.Collection.extend({ model: Todo, localStorage: new Store("todos"), done: function() { return this.filter(function(todo) { return todo.get('done'); }); }, remaining: function() { return this.without.apply( this, this.done()); } });
  • 27. STRUCTURE Backbone Collection window.TodoList = Backbone.Collection.extend({ model: Todo, localStorage: new Store("todos"), done: function() { return this.filter(function(todo) { return todo.get('done'); }); }, remaining: function() { return this.without.apply( this, this.done()); } });
  • 28. STRUCTURE Backbone Collection window.TodoList = Backbone.Collection.extend({ model: Todo, localStorage: new Store("todos"), done: function() { return this.filter(function(todo) { return todo.get('done'); }); }, remaining: function() { return this.without.apply( this, this.done()); } });
  • 29. STRUCTURE Backbone View window.TodoView = Backbone.View.extend({ tagName: "li", template: $("#item-template").template(), events: { "change .check" : "toggleDone", "dblclick .todo-content" : "edit", "click .todo-destroy" : "destroy", "keypress .todo-input" : "updateOnEnter", "blur .todo-input" : "close" },
  • 30. STRUCTURE Backbone View window.TodoView = Backbone.View.extend({ tagName: "li", template: $("#item-template").template(), events: { "change .check" : "toggleDone", "dblclick .todo-content" : "edit", "click .todo-destroy" : "destroy", "keypress .todo-input" : "updateOnEnter", "blur .todo-input" : "close" },
  • 31. STRUCTURE Backbone View window.TodoView = Backbone.View.extend({ tagName: "li", template: $("#item-template").template(), events: { "change .check" : "toggleDone", "dblclick .todo-content" : "edit", "click .todo-destroy" : "destroy", "keypress .todo-input" : "updateOnEnter", "blur .todo-input" : "close" },
  • 32. STRUCTURE JS Template window.TodoView = Backbone.View.extend({ tagName: "li", template: $("#item-template").template(), events: { "change .check" : "toggleDone", "dblclick .todo-content" : "edit", "click .todo-destroy" : "destroy", "keypress .todo-input" : "updateOnEnter", "blur .todo-input" : "close" },
  • 33. STRUCTURE Backbone View window.TodoView = Backbone.View.extend({ tagName: "li", template: $("#item-template").template(), events: { "change .check" : "toggleDone", "dblclick .todo-content" : "edit", "click .todo-destroy" : "destroy", "keypress .todo-input" : "updateOnEnter", "blur .todo-input" : "close" },
  • 34. STRUCTURE Backbone View initialize: function() { _.bindAll(this, 'render', 'close', 'remove', 'edit'); this.model.bind('change', this.render); this.model.bind('destroy', this.remove); }, render: function() { var element = jQuery.tmpl(this.template, this.model.toJSON()); $(this.el).html(element); this.input = this.$(".todo-input"); return this; },
  • 35. STRUCTURE Backbone View initialize: function() { _.bindAll(this, 'render', 'close', 'remove', 'edit'); this.model.bind('change', this.render); this.model.bind('destroy', this.remove); }, render: function() { var element = jQuery.tmpl(this.template, this.model.toJSON()); $(this.el).html(element); this.input = this.$(".todo-input"); return this; },
  • 36. STRUCTURE Backbone View toggleDone: function() { this.model.toggle(); },
  • 37. STRUCTURE Backbone Router var Workspace = Backbone.Router.extend({ routes: { "help": "help" // #help }, help: function() { ... } });
  • 38. STRUCTURE Backbone Router var Workspace = Backbone.Router.extend({ routes: { "help": "help" // #help }, help: function() { ... } });
  • 39. STRUCTURE Backbone Router var Workspace = Backbone.Router.extend({ routes: { "help": "help" // #help }, help: function() { ... } });
  • 40. STRUCTURE Clean Code
  • 42. S TAT E HTTP/1.1 “It is a…stateless protocol” —RFC 2616 (June 1999)
  • 43. S TAT E HTTP/1.1 “It is a…stateless protocol” —RFC 2616 (June 1999) cookies sessions form variables URI parameters
  • 44. S TAT E Server Owns State Client Server
  • 45. S TAT E Request GET / HTTP/1.1 Client Server
  • 46. S TAT E Response HTTP/1.1 200 OK Client Server
  • 47. S TAT E AJAX asynchronicity Client Server
  • 48. S TAT E Infrastructure Client Server
  • 49. S TAT E Infrastructure Client Web Server
  • 50. S TAT E Infrastructure Client Web Server RESTful Application
  • 51. S TAT E Infrastructure Client Web Server RESTful Application Database
  • 52. S TAT E Infrastructure Client JavaScript MVC App. Web Server RESTful API / App. Database
  • 53. S TAT E Infrastructure Client JavaScript MVC App. Local Storage Bo nu s!
  • 55. SPEED JavaScript is Fast Google v8 JS engine —focus on optimizing speed It runs in the browser —cuts out server requests —spares server resources —instantaneous UI
  • 56. SPEED Data Transport JSON data only —no markup
  • 57. SPEED Data Transport JSON data only —no markup { "id": 1, "first_name": "Philip", "last_name": "Poots", "twitter": "@pootsbook"} vs. "<div id="user_1">n<dl>n<dt>Name</dt> n<dd>Philip Poots</dd>n<dt>Twitter handle:</dt>n<dd>@pootsbook</dd>n</dl> n</div>"