SlideShare uma empresa Scribd logo
1 de 60
Baixar para ler 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

Mais conteúdo relacionado

Mais procurados

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
 

Mais procurados (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
 

Semelhante a 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
 

Semelhante a 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
 

Último

DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
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
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
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
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
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
 
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
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
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
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
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
 
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
 
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
 

Último (20)

DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
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
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
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
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
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
 
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
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
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
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
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
 
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
 
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
 

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>"