SlideShare a Scribd company logo
Backbone.js
A Conceptual View
  Ambert Ho




                     ambert@opzi.com
Agenda
• Problems in building web apps	

  • From web development perspective	

  • From software theory perspective	

• Walk through how Backbone solves problems	

• Resources
In a nutshell, Backbone.js 	

Abstracts remote resources into models
and collections of models, 	

 that emit events on state
 change.	

           Allows us to bind view
           code to listen for those
            changes and respond
The web development perspective
 Challenges: Things get hairy when a single interaction
       affects multiple views, or changes lots of data	


• Need to deal with remote resources	

• Organize rendering of views	

• Support navigation	


•  eep views up to date in response to interactions	

 K
   • “jQuery callback soup”
Backbone.js Concepts	

• Model/Collection 	

                     Need to deal with remote resources	

  • Abstracts away network resources 	


• View	

                                  Organize rendering of views	

  • Encapsulate presentation into neat buckets 	



•  ontroller Router	

 C                                        Support navigation	

  •  upport navigation by responding to hash
   S
  changes	



• Event binding	

                         Avoid “jQuery callback soup”	

  • Model and collection emit events
  corresponding to state changes
Obligatory quote from 
famous computer scientist

  “abstraction is the only way we can deal
  with complexity”	

  	

 	

 	

 	

 	

 	

 	

 - Djikstra
Maintainability and Scalability
 •  bstraction
  A                  hide things to limit mental model 

   •  OO   (inheritance, encapsulation)


 •  eparation
  S                of concerns             put things in boxes

   •  MVC    (separate content from presentation)

   •  SOA

 •  ore
  M         specifically, decouple logical entities
 decrease brittleness 

    •  Message Queues (flow of info from processing of info)
    •  Events/notifications
In a nutshell, Backbone.js 	

         abstracts functionality,	

        separates concerns, and
       decouples frontend code.	

If you think about it for a second, this is basically the
    definition of any ‘framework’ from a theoretical
                       perspective 	


                  *side effect: improved readability
The Abstractions
Suppose you want
   to make an
    interface
(this doesn’t include the event binding)
Separated concerns




Decoupling
View




 • Events bound - $.delegate()	

 • DOM structure specified
Case Study	

   time
Model
Events:	

• change:{field}	

• add/remove – to a collection	

• destroy	

• error - if validate() defined	


Features:	

• fetch (expects single JSON object from server)	

• save/destroy	

• validations – manually defined validate()
Collection
Events:	

• add/remove	

• refresh	

• reset	


Features:	

• fetch (expects array response from server)	

• pass in comparator for auto-sort	

• pluck(attr)	

  • Grab attribute for every member of	

    the collection
Controller Router




 • Path components get passed in as args	

 • Calling Backbone.history.start() binds the
 router to url hash change events	

   • Pass in {pushState: true} to utilize
   pushState in supported browsers
Misc…
 After you build a few apps, reflect on what’s the nature of
 code organization in a large JS app? How to structure
 interactions between objects?	


   Zakas on Yahoo’s JS architecture: Application
   core and modules, a sandbox sits in between to
   decouple the object layer (sounds a bit like
   dependency injection)	

   http://www.slideshare.net/nzakas/scalable-javascript-application-
   architecture	



   Event Aggregator: centralize application control
   using an Observer	

   http://lostechies.com/derickbailey/2011/07/19/references-routing-and-the-
   event-aggregator-coordinating-views-in-backbone-js/
Alert: memory leaks
 • Google “jquery events memory leaks”	

 • When the controller swaps a view out,	

   • need to make sure to remove views from DOM, or they
   will still be bound	

      • use Backbone.View.remove()	

   	

   • need to unbind events	

      • use Backbone.View.unbind()
Readability
Resources
Thoughtbot’s writing a book
in progress (thanks for heads
up Harlow)


    http://workshops.thoughtbot.com/
            backbone-js-on-rails
Alternatives
•  Sproutcore      2.0
  •  Modular,decoupled (previous versions monolithic)
  •  Fragmented? (always a risk for the community, like Rails and Merb)

•  PJAX
  •  https://github.com/defunkt/jquery-pjax
  •  Works    on browsers with history.pushState
  •  Still incur network latency and server rendering time

•  Knockout.js
  •  MVVM,  declarative event bindings 
      •  input data-bind=“value: doSomething” />
       <
  •  Separates view from logic
      •  good for shops that have designers do the html/css
Testing
• Stub out server responses - http://sinonjs.org/docs/#useFakeXMLHttpRequest	

• Three part blog post http://tinnedfruit.com/2011/03/03/testing-backbone-apps-with-
jasmine-sinon.html	

• Object factory - https://github.com/SupportBee/Backbone-Factory	



Single Page Apps
http://blog.nodejitsu.com/single-page-apps-with-nodejs	



Annotated Source
http://documentcloud.github.com/backbone/docs/backbone.html	



Community
https://groups.google.com/group/backbonejs
Slides
 http://www.slideshare.net/ambertch


Contact
  ambert@opzi.com


Questions?
Ad

More Related Content

What's hot (20)

Tikal's Backbone_js introduction workshop
Tikal's Backbone_js introduction workshopTikal's Backbone_js introduction workshop
Tikal's Backbone_js introduction workshop
Tikal Knowledge
 
Introduction to backbone js
Introduction to backbone jsIntroduction to backbone js
Introduction to backbone js
Mindfire Solutions
 
Backbonejs
BackbonejsBackbonejs
Backbonejs
SHASHI KUMAR
 
React.js - and how it changed our thinking about UI
React.js - and how it changed our thinking about UIReact.js - and how it changed our thinking about UI
React.js - and how it changed our thinking about UI
Marcin Grzywaczewski
 
Modular & Event driven UI Architecture
Modular & Event driven UI ArchitectureModular & Event driven UI Architecture
Modular & Event driven UI Architecture
Vytautas Butkus
 
Wheel.js
Wheel.jsWheel.js
Wheel.js
baccigalupi
 
Kickstarting Node.js Projects with Yeoman
Kickstarting Node.js Projects with YeomanKickstarting Node.js Projects with Yeoman
Kickstarting Node.js Projects with Yeoman
Patrick Buergin
 
BackboneJS Training - Giving Backbone to your applications
BackboneJS Training - Giving Backbone to your applicationsBackboneJS Training - Giving Backbone to your applications
BackboneJS Training - Giving Backbone to your applications
Joseph Khan
 
Intro to Sails.js
Intro to Sails.jsIntro to Sails.js
Intro to Sails.js
DevOpsDays Austin 2014
 
Integrating Browserify with Sprockets
Integrating Browserify with SprocketsIntegrating Browserify with Sprockets
Integrating Browserify with Sprockets
Spike Brehm
 
Integrating AngularJS with Drupal 7
Integrating AngularJS with Drupal 7Integrating AngularJS with Drupal 7
Integrating AngularJS with Drupal 7
andrewmriley
 
KnockoutJS and MVVM
KnockoutJS and MVVMKnockoutJS and MVVM
KnockoutJS and MVVM
Manvendra Singh
 
An Overview on Nuxt.js
An Overview on Nuxt.jsAn Overview on Nuxt.js
An Overview on Nuxt.js
Squash Apps Pvt Ltd
 
Azure functions and container instances
Azure functions and container instancesAzure functions and container instances
Azure functions and container instances
John Staveley
 
ProtoPie with Electron
ProtoPie with ElectronProtoPie with Electron
ProtoPie with Electron
Scotty Kim
 
Put a little Backbone in your WordPress
Put a little Backbone in your WordPressPut a little Backbone in your WordPress
Put a little Backbone in your WordPress
adamsilverstein
 
WordPress as the Backbone(.js)
WordPress as the Backbone(.js)WordPress as the Backbone(.js)
WordPress as the Backbone(.js)
Beau Lebens
 
Drupal point of vue
Drupal point of vueDrupal point of vue
Drupal point of vue
David Ličen
 
Javascript for Wep Apps
Javascript for Wep AppsJavascript for Wep Apps
Javascript for Wep Apps
Michael Puckett
 
JavaScript para Graficos y Visualizacion de Datos
JavaScript para Graficos y Visualizacion de DatosJavaScript para Graficos y Visualizacion de Datos
JavaScript para Graficos y Visualizacion de Datos
philogb
 
Tikal's Backbone_js introduction workshop
Tikal's Backbone_js introduction workshopTikal's Backbone_js introduction workshop
Tikal's Backbone_js introduction workshop
Tikal Knowledge
 
React.js - and how it changed our thinking about UI
React.js - and how it changed our thinking about UIReact.js - and how it changed our thinking about UI
React.js - and how it changed our thinking about UI
Marcin Grzywaczewski
 
Modular & Event driven UI Architecture
Modular & Event driven UI ArchitectureModular & Event driven UI Architecture
Modular & Event driven UI Architecture
Vytautas Butkus
 
Kickstarting Node.js Projects with Yeoman
Kickstarting Node.js Projects with YeomanKickstarting Node.js Projects with Yeoman
Kickstarting Node.js Projects with Yeoman
Patrick Buergin
 
BackboneJS Training - Giving Backbone to your applications
BackboneJS Training - Giving Backbone to your applicationsBackboneJS Training - Giving Backbone to your applications
BackboneJS Training - Giving Backbone to your applications
Joseph Khan
 
Integrating Browserify with Sprockets
Integrating Browserify with SprocketsIntegrating Browserify with Sprockets
Integrating Browserify with Sprockets
Spike Brehm
 
Integrating AngularJS with Drupal 7
Integrating AngularJS with Drupal 7Integrating AngularJS with Drupal 7
Integrating AngularJS with Drupal 7
andrewmriley
 
Azure functions and container instances
Azure functions and container instancesAzure functions and container instances
Azure functions and container instances
John Staveley
 
ProtoPie with Electron
ProtoPie with ElectronProtoPie with Electron
ProtoPie with Electron
Scotty Kim
 
Put a little Backbone in your WordPress
Put a little Backbone in your WordPressPut a little Backbone in your WordPress
Put a little Backbone in your WordPress
adamsilverstein
 
WordPress as the Backbone(.js)
WordPress as the Backbone(.js)WordPress as the Backbone(.js)
WordPress as the Backbone(.js)
Beau Lebens
 
Drupal point of vue
Drupal point of vueDrupal point of vue
Drupal point of vue
David Ličen
 
JavaScript para Graficos y Visualizacion de Datos
JavaScript para Graficos y Visualizacion de DatosJavaScript para Graficos y Visualizacion de Datos
JavaScript para Graficos y Visualizacion de Datos
philogb
 

Similar to Backbone.js slides (20)

Backbone.js
Backbone.jsBackbone.js
Backbone.js
Ivano Malavolta
 
Backbone JS for mobile apps
Backbone JS for mobile appsBackbone JS for mobile apps
Backbone JS for mobile apps
Ivano Malavolta
 
[2015/2016] Backbone JS
[2015/2016] Backbone JS[2015/2016] Backbone JS
[2015/2016] Backbone JS
Ivano Malavolta
 
MV* presentation frameworks in Javascript: en garde, pret, allez!
MV* presentation frameworks in Javascript: en garde, pret, allez!MV* presentation frameworks in Javascript: en garde, pret, allez!
MV* presentation frameworks in Javascript: en garde, pret, allez!
Roberto Messora
 
Backbone.js
Backbone.jsBackbone.js
Backbone.js
Ivano Malavolta
 
MSc Enterprise Systems Development Guest Lecture at UniS (2/12/09)
MSc Enterprise Systems Development Guest Lecture at UniS (2/12/09)MSc Enterprise Systems Development Guest Lecture at UniS (2/12/09)
MSc Enterprise Systems Development Guest Lecture at UniS (2/12/09)
Daniel Bryant
 
Knockout implementing mvvm in java script with knockout
Knockout implementing mvvm in java script with knockoutKnockout implementing mvvm in java script with knockout
Knockout implementing mvvm in java script with knockout
Andoni Arroyo
 
Developing maintainable Cordova applications
Developing maintainable Cordova applicationsDeveloping maintainable Cordova applications
Developing maintainable Cordova applications
Ivano Malavolta
 
MeteorJS Introduction
MeteorJS IntroductionMeteorJS Introduction
MeteorJS Introduction
Nitya Narasimhan
 
Apache Cayenne for WO Devs
Apache Cayenne for WO DevsApache Cayenne for WO Devs
Apache Cayenne for WO Devs
WO Community
 
Angular or Backbone: Go Mobile!
Angular or Backbone: Go Mobile!Angular or Backbone: Go Mobile!
Angular or Backbone: Go Mobile!
Doris Chen
 
MVC + ORM (with project implementation)
MVC + ORM (with project implementation)MVC + ORM (with project implementation)
MVC + ORM (with project implementation)
Prateek Chauhan
 
Show Some Spine!
Show Some Spine!Show Some Spine!
Show Some Spine!
Geoff Gerrietts
 
JavaOne_2010
JavaOne_2010JavaOne_2010
JavaOne_2010
Tadaya Tsuyukubo
 
Backbone introdunction
Backbone introdunctionBackbone introdunction
Backbone introdunction
mzxbupt
 
Backbone Dev Talk by Max Mamis
Backbone Dev Talk by Max MamisBackbone Dev Talk by Max Mamis
Backbone Dev Talk by Max Mamis
Prolific Interactive
 
React.js at Cortex
React.js at CortexReact.js at Cortex
React.js at Cortex
Geoff Harcourt
 
Comparing Angular and React JS for SPAs
Comparing Angular and React JS for SPAsComparing Angular and React JS for SPAs
Comparing Angular and React JS for SPAs
Jennifer Estrada
 
Hybernat and structs, spring classes in mumbai
Hybernat and structs, spring classes in mumbaiHybernat and structs, spring classes in mumbai
Hybernat and structs, spring classes in mumbai
Vibrant Technologies & Computers
 
Gnizr Architecture (for developers)
Gnizr Architecture (for developers)Gnizr Architecture (for developers)
Gnizr Architecture (for developers)
hchen1
 
Backbone JS for mobile apps
Backbone JS for mobile appsBackbone JS for mobile apps
Backbone JS for mobile apps
Ivano Malavolta
 
MV* presentation frameworks in Javascript: en garde, pret, allez!
MV* presentation frameworks in Javascript: en garde, pret, allez!MV* presentation frameworks in Javascript: en garde, pret, allez!
MV* presentation frameworks in Javascript: en garde, pret, allez!
Roberto Messora
 
MSc Enterprise Systems Development Guest Lecture at UniS (2/12/09)
MSc Enterprise Systems Development Guest Lecture at UniS (2/12/09)MSc Enterprise Systems Development Guest Lecture at UniS (2/12/09)
MSc Enterprise Systems Development Guest Lecture at UniS (2/12/09)
Daniel Bryant
 
Knockout implementing mvvm in java script with knockout
Knockout implementing mvvm in java script with knockoutKnockout implementing mvvm in java script with knockout
Knockout implementing mvvm in java script with knockout
Andoni Arroyo
 
Developing maintainable Cordova applications
Developing maintainable Cordova applicationsDeveloping maintainable Cordova applications
Developing maintainable Cordova applications
Ivano Malavolta
 
Apache Cayenne for WO Devs
Apache Cayenne for WO DevsApache Cayenne for WO Devs
Apache Cayenne for WO Devs
WO Community
 
Angular or Backbone: Go Mobile!
Angular or Backbone: Go Mobile!Angular or Backbone: Go Mobile!
Angular or Backbone: Go Mobile!
Doris Chen
 
MVC + ORM (with project implementation)
MVC + ORM (with project implementation)MVC + ORM (with project implementation)
MVC + ORM (with project implementation)
Prateek Chauhan
 
Backbone introdunction
Backbone introdunctionBackbone introdunction
Backbone introdunction
mzxbupt
 
Comparing Angular and React JS for SPAs
Comparing Angular and React JS for SPAsComparing Angular and React JS for SPAs
Comparing Angular and React JS for SPAs
Jennifer Estrada
 
Gnizr Architecture (for developers)
Gnizr Architecture (for developers)Gnizr Architecture (for developers)
Gnizr Architecture (for developers)
hchen1
 
Ad

Recently uploaded (20)

DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Ad

Backbone.js slides

  • 2. Agenda • Problems in building web apps • From web development perspective • From software theory perspective • Walk through how Backbone solves problems • Resources
  • 3. In a nutshell, Backbone.js Abstracts remote resources into models and collections of models, that emit events on state change. Allows us to bind view code to listen for those changes and respond
  • 4. The web development perspective Challenges: Things get hairy when a single interaction affects multiple views, or changes lots of data • Need to deal with remote resources • Organize rendering of views • Support navigation •  eep views up to date in response to interactions K • “jQuery callback soup”
  • 5. Backbone.js Concepts • Model/Collection Need to deal with remote resources • Abstracts away network resources • View Organize rendering of views • Encapsulate presentation into neat buckets •  ontroller Router C Support navigation •  upport navigation by responding to hash S changes • Event binding Avoid “jQuery callback soup” • Model and collection emit events corresponding to state changes
  • 6. Obligatory quote from famous computer scientist “abstraction is the only way we can deal with complexity” - Djikstra
  • 7. Maintainability and Scalability •  bstraction A hide things to limit mental model •  OO (inheritance, encapsulation) •  eparation S of concerns put things in boxes •  MVC (separate content from presentation) •  SOA •  ore M specifically, decouple logical entities decrease brittleness •  Message Queues (flow of info from processing of info) •  Events/notifications
  • 8. In a nutshell, Backbone.js abstracts functionality, separates concerns, and decouples frontend code. If you think about it for a second, this is basically the definition of any ‘framework’ from a theoretical perspective *side effect: improved readability
  • 10. Suppose you want to make an interface
  • 11. (this doesn’t include the event binding)
  • 13. View • Events bound - $.delegate() • DOM structure specified
  • 14. Case Study time
  • 15. Model Events: • change:{field} • add/remove – to a collection • destroy • error - if validate() defined Features: • fetch (expects single JSON object from server) • save/destroy • validations – manually defined validate()
  • 16. Collection Events: • add/remove • refresh • reset Features: • fetch (expects array response from server) • pass in comparator for auto-sort • pluck(attr) • Grab attribute for every member of the collection
  • 17. Controller Router • Path components get passed in as args • Calling Backbone.history.start() binds the router to url hash change events • Pass in {pushState: true} to utilize pushState in supported browsers
  • 18. Misc… After you build a few apps, reflect on what’s the nature of code organization in a large JS app? How to structure interactions between objects? Zakas on Yahoo’s JS architecture: Application core and modules, a sandbox sits in between to decouple the object layer (sounds a bit like dependency injection) http://www.slideshare.net/nzakas/scalable-javascript-application- architecture Event Aggregator: centralize application control using an Observer http://lostechies.com/derickbailey/2011/07/19/references-routing-and-the- event-aggregator-coordinating-views-in-backbone-js/
  • 19. Alert: memory leaks • Google “jquery events memory leaks” • When the controller swaps a view out, • need to make sure to remove views from DOM, or they will still be bound • use Backbone.View.remove() • need to unbind events • use Backbone.View.unbind()
  • 22. Thoughtbot’s writing a book in progress (thanks for heads up Harlow) http://workshops.thoughtbot.com/ backbone-js-on-rails
  • 23. Alternatives •  Sproutcore 2.0 •  Modular,decoupled (previous versions monolithic) •  Fragmented? (always a risk for the community, like Rails and Merb) •  PJAX •  https://github.com/defunkt/jquery-pjax •  Works on browsers with history.pushState •  Still incur network latency and server rendering time •  Knockout.js •  MVVM, declarative event bindings •  input data-bind=“value: doSomething” /> < •  Separates view from logic •  good for shops that have designers do the html/css
  • 24. Testing • Stub out server responses - http://sinonjs.org/docs/#useFakeXMLHttpRequest • Three part blog post http://tinnedfruit.com/2011/03/03/testing-backbone-apps-with- jasmine-sinon.html • Object factory - https://github.com/SupportBee/Backbone-Factory Single Page Apps http://blog.nodejitsu.com/single-page-apps-with-nodejs Annotated Source http://documentcloud.github.com/backbone/docs/backbone.html Community https://groups.google.com/group/backbonejs

Editor's Notes

  • #2: Introduce Opzi – in addition to Backbone, we use Node, and mongoDB for the flexible schema Used Backbone on previous projects, discover better ways to use it, and realize more and more that the simplicity of this library
  • #3: I think that demos and tutorials can be walked through any time, so this presentation will talk more about ideas. we’ll talk about motivations for why Backbone, both from a practical web dev, and a theoretical perspective then we’ll segway into explaining how Backbone fulfills those motivations Finally I’ll gloss over some resources and reading that the audience can go into from her, including comparisons to other web app frameworks
  • #4: Let’s do a first pass at the highest level summary I could think of
  • #5: First, let’s look at the issue from the web development side, the challenges of single page apps a web app isn’t like web site, more like traditional GUI programming backbone is for that
  • #6: - (next slide) Now lets talk about some theory
  • #12: I have some data, I want to pull it out and represent it.
  • #13: Here we see a snippet of Backbone code to generate the same view. The rendering of the view has been abstracted away Also we have separated the concern of displaying the data (views) from storing the data (models)
  • #14: One thing to note here is that Backbone views have an ‘el’ concept. The events that we bind are in that context. So it will not work if #delete-button, #save-button exist outside of the view’s element.
  • #16: If you define a validate method, it will be run any time the model gets persisted