SlideShare a Scribd company logo
Javascript applications and the
quest for Sanity
Facts about Javascript

    Javascript was spawned and mutated (not born and nurtured) in the dank halls of
    Netscape tor.
Peace across the land
Modern Javascript is culture
The Good Parts

   Javascript is a flexible, loosley typed language.

   It can be and has been bent in many different ways.
   eg check out http://dailyjs.com/2012/11/26/js101-proto/
The Good Parts

  Javascript gives us ways to expand and manipulate it.

  Eg) Namespaces

  	   Single Global Variables
  	
  	   Object Literals

  	   Nested namespaces
The Good Parts

   eg) Closures

   	   Passing information back and forth

   	   Returning Functions

   	   Reference instead of Create
   	   via http://stackoverflow.com/questions/111102/how-do-javascript-closures-work
The Bad Part

   Gets Messy Quickly

   	Why?
   	
   		 SCOPE and @#%*(@#$* Global Variables


   Not always consistent

   	   eg) Semicolon insertion
The Bad Part

   Really easy to let it get away from you.
Structures and Exploration




                     http://forum.woodenboat.com/showthread.php?112363-
                     Voronoi-Diagrams-in-Nature
You want to make a web app?

   Lets forget about the code for a minute.



   What are you trying to solve?

   Who is going to use your application?

   Where does your tool live?

   How much time do you have to make it?

   What does it actually do?
Sketch and Sketch and Sketch
Formalize your sketching
List out what you need to do
Sketch a bit more
Let’s build something now...?
Model View Controller




   http://www.codinghorror.com/blog/2008/05/understanding-model-view-controller.html
Model View Presenter
Model View ********@
BackboneJS
Intro to Backbone

   What is Backbone?

   	   Backbone is an awesome frameworks for organizing javascript projects.

   	   Set of tools that help you manage complexity.

   	   Set of methods and formalized conventions that are a given in modern Javascript

   	   Powerful way to approach building Single Page Applications
Backbone Building Blocks

   Model

   Collection

   View

   Router
Backbone Model

   Represents your data and what it’s
   supposed to do.

   The idea of the thing, not the thing.

   Holds defaults, holds checking
   functions.
Backbone Collection

   Collections hold groups of model data.

   Says how these models are stored and
   where they go when they die.

   Orders the data and lets you get informa-
   tion about it.
Backbone View

   Views are how the data and differ-
   ent parts of your application are
   represented.

   How do you render out your ToDo,
   or your portfolio piece?

   What are the different parts of
   your app? (This is why we sketch,
   by the way!)
Backbone Router

   Routers help you manage states.

   States are how your application know
   what’s what.

   Our different states:
   Standing
   Sitting
   Lying down
   Sleeping
   Dreaming

   How are those states represented?
And ‘lo, magic.
Framework to form

   Challenge is to translate the framework that Backbone gives us into the final applica-
   tion.

   Lets look at:

   	Data

   	Templates

   	Behaviour
Data and your app

   Most modern applications require a database.

   Localstorage is an HTML5 spec that lets you keep and persist info all within the client
   side, i.e. the browser. But doesn’t let you share across.

   Backbone lets you drop in localstorage first, and worry about the DB later.

   eg) Meaning Clock started off as a localstorage app before I wrote the NodeJS server
   with a MongoDB database.




   This is why we make lists. They will help you decide what is best for you.
Backbone.sync

   Backbone.sync is a method to synchronize your collections and models across
   systems.

   So, how do I make this work with my server and data?

   var methodMap = {
   	 ’create’: ’POST’
   	 , ’update’: ’PUT’
   	 , ’delete’: ’DELETE’
   	 , ’read’: ’GET’
   };


   Comes with a default way to manage data via the CRUD method.
   Great for Node or Ruby on Rails.

   Can be overridden if you want something custom.
Local vs. Remote storage
Templates

           Templates are how you separate HTML from JS.
           Make sense of the different KNOWN (again, sketching) states of your app.


MyApp.js



                                                                Index.jade
Underscore.js

   Framework for dealing with data.

   Powers a lot of the BackboneJS tools, and is hugely worth learning.

   Strong way to work with models and views.
That el thing

    The el element refers to a DOM element in the backbone.view

    Few different ways to deal with it.

    $el is an easy to use jquery object

    this.el is the standard Javascript DOM object.

    I often do

    this.$el.someJqueryFunction().anotherChainedjQueryFunction();

    another option is this

    	$(this.el).html(this.template);

    This reners the template defined in
    	 el: $(‘#inviteToEnter’)
    		 , template: _.template($(“#blankMeaning”).html())
    to #inviteToEnter
Lets Look At Some Code
My Own App, The Meaning Clock   A much better programmed app, todoMVC

           Javascript
Things to remember

   Backbone is a FRAMEWORK, not a solution per se.
   It helps you organize your thinking and avoid getting overwhelmed if you use it right.


   Think and Sketch first, code later.
   It’s hugely valuable to do both, but drawing your app to scale on a piece of paper
   and pretending to interact with it is a hell of a lot more time effective than coding the
   wrong thing eight times.

   Use documentation and resources
   See the github repo for resources,
   http://github.com/readywater/backbonejs_workshop
Andrew Lovett-Barron

@readywater

http://readywater.ca

http://relaystudio.com

http://github.com/readywater

More Related Content

What's hot (19)

PDF
The Art of AngularJS in 2015 - Angular Summit 2015
Matt Raible
 
PDF
Intro to emberjs
Mandy Pao
 
PDF
Dependency Management with RequireJS
Aaronius
 
PDF
Rails course day 7
Al Sayed Gamal
 
PDF
Javascript MVC & Backbone Tips & Tricks
Hjörtur Hilmarsson
 
PDF
Introduction to Backbone.js for Rails developers
AoteaStudios
 
PDF
jQuery
Ivano Malavolta
 
PDF
In-depth changes to Drupal 8 javascript
Théodore Biadala
 
PPT
Web&java. jsp
Asya Dudnik
 
PDF
Short intro to JQuery and Modernizr
Jussi Pohjolainen
 
PPTX
JQuery
Jussi Pohjolainen
 
PPTX
Getting Started with Angular JS
Akshay Mathur
 
PPT
Integrating AngularJS with Drupal 7
andrewmriley
 
PPT
Phase2 OpenPublish Presentation SF SemWeb Meetup, April 28, 2009
Krista Thomas
 
PDF
Upgrade your javascript to drupal 8
Théodore Biadala
 
PDF
Multi screen HTML5
Ron Reiter
 
PDF
Intro To Mvc Development In Php
funkatron
 
PDF
Effective cassandra development with achilles
Duyhai Doan
 
PDF
Spca2014 hillier 3rd party_javascript_libraries
NCCOMMS
 
The Art of AngularJS in 2015 - Angular Summit 2015
Matt Raible
 
Intro to emberjs
Mandy Pao
 
Dependency Management with RequireJS
Aaronius
 
Rails course day 7
Al Sayed Gamal
 
Javascript MVC & Backbone Tips & Tricks
Hjörtur Hilmarsson
 
Introduction to Backbone.js for Rails developers
AoteaStudios
 
In-depth changes to Drupal 8 javascript
Théodore Biadala
 
Web&java. jsp
Asya Dudnik
 
Short intro to JQuery and Modernizr
Jussi Pohjolainen
 
Getting Started with Angular JS
Akshay Mathur
 
Integrating AngularJS with Drupal 7
andrewmriley
 
Phase2 OpenPublish Presentation SF SemWeb Meetup, April 28, 2009
Krista Thomas
 
Upgrade your javascript to drupal 8
Théodore Biadala
 
Multi screen HTML5
Ron Reiter
 
Intro To Mvc Development In Php
funkatron
 
Effective cassandra development with achilles
Duyhai Doan
 
Spca2014 hillier 3rd party_javascript_libraries
NCCOMMS
 

Viewers also liked (6)

PDF
Backbonejs Full Stack
Artyom Trityak
 
PDF
[XECon2016] A-3 박형식 Frontend stack의 변화 : jQuery, BackboneJS, ReactJS 중심으로
XpressEngine
 
PDF
Drupal8 + AngularJS
Daniel Kanchev
 
PPTX
Top 5 Javascript Frameworks for Web and Mobile App Development
Algoworks Inc
 
PDF
JS Framework Comparison - An infographic
InApp
 
PPTX
Single Page Applications with AngularJS 2.0
Sumanth Chinthagunta
 
Backbonejs Full Stack
Artyom Trityak
 
[XECon2016] A-3 박형식 Frontend stack의 변화 : jQuery, BackboneJS, ReactJS 중심으로
XpressEngine
 
Drupal8 + AngularJS
Daniel Kanchev
 
Top 5 Javascript Frameworks for Web and Mobile App Development
Algoworks Inc
 
JS Framework Comparison - An infographic
InApp
 
Single Page Applications with AngularJS 2.0
Sumanth Chinthagunta
 
Ad

Similar to Intro to BackboneJS + Intermediate Javascript (20)

PDF
Developing Backbonejs Applications Early Release Addy Osmani
littelenkali
 
PDF
Developing maintainable Cordova applications
Ivano Malavolta
 
PDF
Backbone.js slides
Ambert Ho
 
PDF
Single Page Applications
Massimo Iacolare
 
PDF
Developing Backbone js Applications Addy Osmani
leitaduminy
 
PDF
[2015/2016] Backbone JS
Ivano Malavolta
 
PDF
Backbone JS for mobile apps
Ivano Malavolta
 
PDF
Instant download Developing Backbone js Applications Addy Osmani pdf all chapter
dinetvenitja
 
PDF
Backbone.js
Ivano Malavolta
 
PPTX
Creating Single Page Web App using Backbone JS
Akshay Mathur
 
PPTX
Backbone.js
VO Tho
 
PDF
Viking academy backbone.js
Bert Wijnants
 
PDF
Backbone.js
Ivano Malavolta
 
PPT
Backbone.js
Knoldus Inc.
 
PPTX
Backbone the Good Parts
Renan Carvalho
 
PPTX
Backbone
Sayed Ahmed
 
PPT
Intro to-html-backbone
zonathen
 
PPTX
Introduction to Backbone.js
Pragnesh Vaghela
 
KEY
Backbonification for dummies - Arrrrug 10/1/2012
Dimitri de Putte
 
PPSX
Introduction to backbone_js
Mohammed Saqib
 
Developing Backbonejs Applications Early Release Addy Osmani
littelenkali
 
Developing maintainable Cordova applications
Ivano Malavolta
 
Backbone.js slides
Ambert Ho
 
Single Page Applications
Massimo Iacolare
 
Developing Backbone js Applications Addy Osmani
leitaduminy
 
[2015/2016] Backbone JS
Ivano Malavolta
 
Backbone JS for mobile apps
Ivano Malavolta
 
Instant download Developing Backbone js Applications Addy Osmani pdf all chapter
dinetvenitja
 
Backbone.js
Ivano Malavolta
 
Creating Single Page Web App using Backbone JS
Akshay Mathur
 
Backbone.js
VO Tho
 
Viking academy backbone.js
Bert Wijnants
 
Backbone.js
Ivano Malavolta
 
Backbone.js
Knoldus Inc.
 
Backbone the Good Parts
Renan Carvalho
 
Backbone
Sayed Ahmed
 
Intro to-html-backbone
zonathen
 
Introduction to Backbone.js
Pragnesh Vaghela
 
Backbonification for dummies - Arrrrug 10/1/2012
Dimitri de Putte
 
Introduction to backbone_js
Mohammed Saqib
 
Ad

More from Andrew Lovett-Barron (6)

PDF
SF Critical Design meetup: Designed Futures in a non-linear world
Andrew Lovett-Barron
 
PDF
GAFFTA Talk on Decay of Digital Things
Andrew Lovett-Barron
 
PDF
Having Conversations through Technology in Public Space
Andrew Lovett-Barron
 
PDF
Seeing Like Software
Andrew Lovett-Barron
 
PDF
Prototyping for Communication
Andrew Lovett-Barron
 
PDF
Pechakucha 2012 Ambient Technology
Andrew Lovett-Barron
 
SF Critical Design meetup: Designed Futures in a non-linear world
Andrew Lovett-Barron
 
GAFFTA Talk on Decay of Digital Things
Andrew Lovett-Barron
 
Having Conversations through Technology in Public Space
Andrew Lovett-Barron
 
Seeing Like Software
Andrew Lovett-Barron
 
Prototyping for Communication
Andrew Lovett-Barron
 
Pechakucha 2012 Ambient Technology
Andrew Lovett-Barron
 

Recently uploaded (20)

PDF
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PPTX
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PPTX
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 

Intro to BackboneJS + Intermediate Javascript

  • 1. Javascript applications and the quest for Sanity
  • 2. Facts about Javascript Javascript was spawned and mutated (not born and nurtured) in the dank halls of Netscape tor.
  • 5. The Good Parts Javascript is a flexible, loosley typed language. It can be and has been bent in many different ways. eg check out http://dailyjs.com/2012/11/26/js101-proto/
  • 6. The Good Parts Javascript gives us ways to expand and manipulate it. Eg) Namespaces Single Global Variables Object Literals Nested namespaces
  • 7. The Good Parts eg) Closures Passing information back and forth Returning Functions Reference instead of Create via http://stackoverflow.com/questions/111102/how-do-javascript-closures-work
  • 8. The Bad Part Gets Messy Quickly Why? SCOPE and @#%*(@#$* Global Variables Not always consistent eg) Semicolon insertion
  • 9. The Bad Part Really easy to let it get away from you.
  • 10. Structures and Exploration http://forum.woodenboat.com/showthread.php?112363- Voronoi-Diagrams-in-Nature
  • 11. You want to make a web app? Lets forget about the code for a minute. What are you trying to solve? Who is going to use your application? Where does your tool live? How much time do you have to make it? What does it actually do?
  • 12. Sketch and Sketch and Sketch
  • 14. List out what you need to do
  • 15. Sketch a bit more
  • 17. Model View Controller http://www.codinghorror.com/blog/2008/05/understanding-model-view-controller.html
  • 21. Intro to Backbone What is Backbone? Backbone is an awesome frameworks for organizing javascript projects. Set of tools that help you manage complexity. Set of methods and formalized conventions that are a given in modern Javascript Powerful way to approach building Single Page Applications
  • 22. Backbone Building Blocks Model Collection View Router
  • 23. Backbone Model Represents your data and what it’s supposed to do. The idea of the thing, not the thing. Holds defaults, holds checking functions.
  • 24. Backbone Collection Collections hold groups of model data. Says how these models are stored and where they go when they die. Orders the data and lets you get informa- tion about it.
  • 25. Backbone View Views are how the data and differ- ent parts of your application are represented. How do you render out your ToDo, or your portfolio piece? What are the different parts of your app? (This is why we sketch, by the way!)
  • 26. Backbone Router Routers help you manage states. States are how your application know what’s what. Our different states: Standing Sitting Lying down Sleeping Dreaming How are those states represented?
  • 28. Framework to form Challenge is to translate the framework that Backbone gives us into the final applica- tion. Lets look at: Data Templates Behaviour
  • 29. Data and your app Most modern applications require a database. Localstorage is an HTML5 spec that lets you keep and persist info all within the client side, i.e. the browser. But doesn’t let you share across. Backbone lets you drop in localstorage first, and worry about the DB later. eg) Meaning Clock started off as a localstorage app before I wrote the NodeJS server with a MongoDB database. This is why we make lists. They will help you decide what is best for you.
  • 30. Backbone.sync Backbone.sync is a method to synchronize your collections and models across systems. So, how do I make this work with my server and data? var methodMap = { ’create’: ’POST’ , ’update’: ’PUT’ , ’delete’: ’DELETE’ , ’read’: ’GET’ }; Comes with a default way to manage data via the CRUD method. Great for Node or Ruby on Rails. Can be overridden if you want something custom.
  • 31. Local vs. Remote storage
  • 32. Templates Templates are how you separate HTML from JS. Make sense of the different KNOWN (again, sketching) states of your app. MyApp.js Index.jade
  • 33. Underscore.js Framework for dealing with data. Powers a lot of the BackboneJS tools, and is hugely worth learning. Strong way to work with models and views.
  • 34. That el thing The el element refers to a DOM element in the backbone.view Few different ways to deal with it. $el is an easy to use jquery object this.el is the standard Javascript DOM object. I often do this.$el.someJqueryFunction().anotherChainedjQueryFunction(); another option is this $(this.el).html(this.template); This reners the template defined in el: $(‘#inviteToEnter’) , template: _.template($(“#blankMeaning”).html()) to #inviteToEnter
  • 35. Lets Look At Some Code My Own App, The Meaning Clock A much better programmed app, todoMVC Javascript
  • 36. Things to remember Backbone is a FRAMEWORK, not a solution per se. It helps you organize your thinking and avoid getting overwhelmed if you use it right. Think and Sketch first, code later. It’s hugely valuable to do both, but drawing your app to scale on a piece of paper and pretending to interact with it is a hell of a lot more time effective than coding the wrong thing eight times. Use documentation and resources See the github repo for resources, http://github.com/readywater/backbonejs_workshop