SlideShare a Scribd company logo
Balavignesh Kasinathan
Introduction
What?
Backbone.js
Why?
Web Applications Demand
Whom?
Beginners to Intermediate
*Beginners => Basic JS + Jquery
Plan
Day 1:
1.5 hrs JS concepts + Jquery + Underscore library
1.5 hrs Basic Elements of Backbone
Day 2:
1 hr Example with Backbone - Local Storage
1 hr Example with Backbone - Persistance
1 hr Boilerplate, RequireJS
Goal
Understading the necessity of MV* Framework
Understanding the basic elements of
Backbone
Overview on designing web app with backbone
Sharing experience / knowledge
Resources / Books
● http://backbonejs.org/
● http://addyosmani.github.io/backbone-fundame
ntals/
● Javascript The Good Parts – Douglas
Crockford
● https://developer.mozilla.org/en/Learn/JavaScr
ipt
Practice
http://jsfiddle.net/
● jquery 2.1.0
● https://cdnjs.cloudflare.com/ajax/libs/json2/20140204/json2.min.js
● https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.2/underscore-
min.js
● https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.1.2/backbone-min.js
Backbone.js
● Author - Jeremy Ashkenas
● Stable Release - 1.1.2
● License - MIT
● http://backbonejs.org/
● Dependency
Underscore.js -> http://underscorejs.org/
JS Frameworks
https://www.airpair.com/js/javascript-framework
-comparison
Testimonials
● Digg
● LinkedIn Mobile
● Bit Torrent
● Wordpress
● Documentcloud
MVC -Design Pattern
Image Source - http://addyosmani.github.io/backbone-fundamentals/
JS OOP Basics- DataTypes
● Numbers,
● Strings,
● Booleans,
● null,
● undefined
● Objects ( arrays, functions, regex, objects)
JS OOP Basics - Object
● Objects in JavaScript are class-free.
● Prototypal programing language
●
http://jsfiddle.net/kbalavignesh/4m8kc6gv/
JS OOP Basics -Reference
● Objects are passed around by reference. They are
never copied.
●
http://jsfiddle.net/kbalavignesh/d5g5k0tL/
JS OOP Basics- Prototype
● Object.prototype - an object that comes standard
with JavaScript.
●
http://jsfiddle.net/kbalavignesh/rp68Ln5s/
● Delegation
JS OOP Basics - Global abatement
●
http://jsfiddle.net/kbalavignesh/s6njz5wz/
JS OOP Basics - Functions
● Functions in JavaScript are objects.
● Function objects are linked to Function.prototype
(which is itself linked to Object.prototype ).
● http://jsfiddle.net/kbalavignesh/a92f3aos/
JS OOP Basics -Closure
● A closure is a function having access to the parent
scope, even after the parent function has closed.
●
http://jsfiddle.net/kbalavignesh/xq5qmz9n/
JS OOP Basics -Arrays
● Array.prototype
var empty = [];
var numbers = ['one', 'two'];
console.log(empty.length);
console.log(numbers.length);
Underscore.js
● forEach - iterate over collections
● sortBy() - sort a collection on a specific attribute
● map() - iterate through a collection, mapping each value through a
transformation function
● pluck() - extract a specific attribute
● size() - return the size of a collection
● isEmpty()- determine whether a collection is empty
● groupBy()- group a collection into groups of like items
● pick() - extract a set of attributes from a model
● omit() - extract all attributes from a model except those listed
● keys() and values() - get lists of attribute names and values
● pairs() - get list of attributes as [key, value] pairs
●
http://jsfiddle.net/kbalavignesh/ujq80qm3/20/
Underscore -Micro Template
● pre compiled templates
● other template engines
Mustache, jQuery-tmpl
● how to select - http://garann.github.io/template-chooser/
● http://www.2ality.com/2012/06/underscore-templates.html
● http://stackoverflow.com/questions/13536262/what-is-javascript-template-
precompiling
Backbone Basic Elements
● Model
● Collections
● View
● Router
● Events
Model
● Holds the attributes
● Takes care of Validation
● Persistance
● Announces updates
● id, idAttribute, cid
● Default, set, get values - https://jsfiddle.net/kbalavignesh/ujq80qm3/9/
● Change Event - https://jsfiddle.net/kbalavignesh/ujq80qm3/10/
● Validation - http://jsfiddle.net/kbalavignesh/ujq80qm3/11/
● Complete Validation - http://jsfiddle.net/kbalavignesh/ujq80qm3/12/
Collection
● Holds models
● Announces add/remove/reset/update model
●
Collection - http://jsfiddle.net/kbalavignesh/ujq80qm3/13/
●
Collection get by id - http://jsfiddle.net/kbalavignesh/ujq80qm3/14/
●
Collection events - http://jsfiddle.net/kbalavignesh/ujq80qm3/15/
●
Collection with underscore functions -
http://jsfiddle.net/kbalavignesh/ujq80qm3/16/
●
Collection sort functions - http://jsfiddle.net/kbalavignesh/ujq80qm3/17/
Persistance
● Collection.fetch() => HTTP GET
● Model.save() => HTTP PUT (for existing model)
● Model.save() => HTTP POST (for new model)
● Model.destroy() => HTTP DELETE
● model.save(attrs, {patch: true}) => HTTP PATCH
Event
● Event within object
- http://jsfiddle.net/kbalavignesh/ujq80qm3/18/
● Event across objects
- http://jsfiddle.net/kbalavignesh/ujq80qm3/19/
View
● Logic to present model
● el - el is basically a reference to a DOM element
and all views must have one
Router & History
● Bookmark
● To Share the link
● To enable backbutton
http://backbonetutorials.com/what-is-a-router/#/route/action
Local Storage - HTML5
● Local storage within browser
● Alternative to cookies
● Can save atleast 5MB
● Stored per domain
localStorage.setItem("name", "Bala");
localStorage.getItem("name");
localStorage.removeItem("name");
http://www.w3schools.com/html/html5_webstorage.asp
TODO List - Example
● Demo - http://backbonejs.org/examples/todos/
● ToDo Examples for all Framework - http://todomvc.com/
● Explanation - http://backbonejs.org/docs/todos.html

More Related Content

Similar to Backbone 4.0

Backday Xebia : Découvrez Spring Boot sur un cas pratique
Backday Xebia : Découvrez Spring Boot sur un cas pratiqueBackday Xebia : Découvrez Spring Boot sur un cas pratique
Backday Xebia : Découvrez Spring Boot sur un cas pratique
Publicis Sapient Engineering
 
Drools & jBPM Workshop London 2013
Drools & jBPM Workshop London 2013Drools & jBPM Workshop London 2013
Drools & jBPM Workshop London 2013
Mauricio (Salaboy) Salatino
 
Creating Modular Test-Driven SPAs with Spring and AngularJS
Creating Modular Test-Driven SPAs with Spring and AngularJSCreating Modular Test-Driven SPAs with Spring and AngularJS
Creating Modular Test-Driven SPAs with Spring and AngularJS
Gunnar Hillert
 
一种多屏时代的通用 web 应用架构
一种多屏时代的通用 web 应用架构一种多屏时代的通用 web 应用架构
一种多屏时代的通用 web 应用架构
勇浩 赖
 
Javascript ui for rest services
Javascript ui for rest servicesJavascript ui for rest services
Javascript ui for rest services
Ioan Eugen Stan
 
Voorhoede - Front-end architecture
Voorhoede - Front-end architectureVoorhoede - Front-end architecture
Voorhoede - Front-end architecture
Jasper Moelker
 
Android gradle-build-system-overview
Android gradle-build-system-overviewAndroid gradle-build-system-overview
Android gradle-build-system-overview
Kevin He
 
AzovDevMeetup 2016 | Angular 2: обзор | Александр Шевнин
AzovDevMeetup 2016 | Angular 2: обзор | Александр ШевнинAzovDevMeetup 2016 | Angular 2: обзор | Александр Шевнин
AzovDevMeetup 2016 | Angular 2: обзор | Александр Шевнин
JSC “Arcadia Inc”
 
There's a Module for That, MIMA Summit 2010
There's a Module for That, MIMA Summit 2010There's a Module for That, MIMA Summit 2010
There's a Module for That, MIMA Summit 2010Emma Jane Hogbin Westby
 
Daniel Steigerwald: EsteJS - javascriptové aplikace robusně, modulárně a komf...
Daniel Steigerwald: EsteJS - javascriptové aplikace robusně, modulárně a komf...Daniel Steigerwald: EsteJS - javascriptové aplikace robusně, modulárně a komf...
Daniel Steigerwald: EsteJS - javascriptové aplikace robusně, modulárně a komf...
Develcz
 
Garelic: Google Analytics as App Performance monitoring
Garelic: Google Analytics as App Performance monitoringGarelic: Google Analytics as App Performance monitoring
Garelic: Google Analytics as App Performance monitoringJano Suchal
 
2016 stop writing javascript frameworks by Joe Gregorio
2016 stop writing javascript frameworks by Joe Gregorio2016 stop writing javascript frameworks by Joe Gregorio
2016 stop writing javascript frameworks by Joe Gregorio
David Zapateria Besteiro
 
Angular.js for beginners
Angular.js for beginners Angular.js for beginners
Angular.js for beginners
Basia Madej
 
Get Ready to Become Google Associate Cloud Engineer
Get Ready to Become Google Associate Cloud EngineerGet Ready to Become Google Associate Cloud Engineer
Get Ready to Become Google Associate Cloud Engineer
Amaaira Johns
 
Module, AMD, RequireJS
Module, AMD, RequireJSModule, AMD, RequireJS
Module, AMD, RequireJS偉格 高
 
The MEAN stack
The MEAN stack The MEAN stack
The MEAN stack
Nattaya Mairittha
 
Angular 2 vs React
Angular 2 vs ReactAngular 2 vs React
Angular 2 vs React
Iran Reyes Fleitas
 
Using redux and angular 2 with meteor
Using redux and angular 2 with meteorUsing redux and angular 2 with meteor
Using redux and angular 2 with meteor
Ken Ono
 
Using redux and angular 2 with meteor
Using redux and angular 2 with meteorUsing redux and angular 2 with meteor
Using redux and angular 2 with meteor
Ken Ono
 

Similar to Backbone 4.0 (20)

Backday Xebia : Découvrez Spring Boot sur un cas pratique
Backday Xebia : Découvrez Spring Boot sur un cas pratiqueBackday Xebia : Découvrez Spring Boot sur un cas pratique
Backday Xebia : Découvrez Spring Boot sur un cas pratique
 
Drools & jBPM Workshop London 2013
Drools & jBPM Workshop London 2013Drools & jBPM Workshop London 2013
Drools & jBPM Workshop London 2013
 
Creating Modular Test-Driven SPAs with Spring and AngularJS
Creating Modular Test-Driven SPAs with Spring and AngularJSCreating Modular Test-Driven SPAs with Spring and AngularJS
Creating Modular Test-Driven SPAs with Spring and AngularJS
 
一种多屏时代的通用 web 应用架构
一种多屏时代的通用 web 应用架构一种多屏时代的通用 web 应用架构
一种多屏时代的通用 web 应用架构
 
Tp web
Tp webTp web
Tp web
 
Javascript ui for rest services
Javascript ui for rest servicesJavascript ui for rest services
Javascript ui for rest services
 
Voorhoede - Front-end architecture
Voorhoede - Front-end architectureVoorhoede - Front-end architecture
Voorhoede - Front-end architecture
 
Android gradle-build-system-overview
Android gradle-build-system-overviewAndroid gradle-build-system-overview
Android gradle-build-system-overview
 
AzovDevMeetup 2016 | Angular 2: обзор | Александр Шевнин
AzovDevMeetup 2016 | Angular 2: обзор | Александр ШевнинAzovDevMeetup 2016 | Angular 2: обзор | Александр Шевнин
AzovDevMeetup 2016 | Angular 2: обзор | Александр Шевнин
 
There's a Module for That, MIMA Summit 2010
There's a Module for That, MIMA Summit 2010There's a Module for That, MIMA Summit 2010
There's a Module for That, MIMA Summit 2010
 
Daniel Steigerwald: EsteJS - javascriptové aplikace robusně, modulárně a komf...
Daniel Steigerwald: EsteJS - javascriptové aplikace robusně, modulárně a komf...Daniel Steigerwald: EsteJS - javascriptové aplikace robusně, modulárně a komf...
Daniel Steigerwald: EsteJS - javascriptové aplikace robusně, modulárně a komf...
 
Garelic: Google Analytics as App Performance monitoring
Garelic: Google Analytics as App Performance monitoringGarelic: Google Analytics as App Performance monitoring
Garelic: Google Analytics as App Performance monitoring
 
2016 stop writing javascript frameworks by Joe Gregorio
2016 stop writing javascript frameworks by Joe Gregorio2016 stop writing javascript frameworks by Joe Gregorio
2016 stop writing javascript frameworks by Joe Gregorio
 
Angular.js for beginners
Angular.js for beginners Angular.js for beginners
Angular.js for beginners
 
Get Ready to Become Google Associate Cloud Engineer
Get Ready to Become Google Associate Cloud EngineerGet Ready to Become Google Associate Cloud Engineer
Get Ready to Become Google Associate Cloud Engineer
 
Module, AMD, RequireJS
Module, AMD, RequireJSModule, AMD, RequireJS
Module, AMD, RequireJS
 
The MEAN stack
The MEAN stack The MEAN stack
The MEAN stack
 
Angular 2 vs React
Angular 2 vs ReactAngular 2 vs React
Angular 2 vs React
 
Using redux and angular 2 with meteor
Using redux and angular 2 with meteorUsing redux and angular 2 with meteor
Using redux and angular 2 with meteor
 
Using redux and angular 2 with meteor
Using redux and angular 2 with meteorUsing redux and angular 2 with meteor
Using redux and angular 2 with meteor
 

More from Balavignesh Kasinathan

John muir
John muirJohn muir
Introduction to Scrum
Introduction to ScrumIntroduction to Scrum
Introduction to Scrum
Balavignesh Kasinathan
 
Introduction to Opensource
Introduction to Opensource Introduction to Opensource
Introduction to Opensource
Balavignesh Kasinathan
 
Version Management with CVS
Version Management with CVSVersion Management with CVS
Version Management with CVS
Balavignesh Kasinathan
 
PHP Secure Programming
PHP Secure ProgrammingPHP Secure Programming
PHP Secure Programming
Balavignesh Kasinathan
 
Trainer GUI for Tesseract
Trainer GUI for TesseractTrainer GUI for Tesseract
Trainer GUI for Tesseract
Balavignesh Kasinathan
 

More from Balavignesh Kasinathan (6)

John muir
John muirJohn muir
John muir
 
Introduction to Scrum
Introduction to ScrumIntroduction to Scrum
Introduction to Scrum
 
Introduction to Opensource
Introduction to Opensource Introduction to Opensource
Introduction to Opensource
 
Version Management with CVS
Version Management with CVSVersion Management with CVS
Version Management with CVS
 
PHP Secure Programming
PHP Secure ProgrammingPHP Secure Programming
PHP Secure Programming
 
Trainer GUI for Tesseract
Trainer GUI for TesseractTrainer GUI for Tesseract
Trainer GUI for Tesseract
 

Recently uploaded

RISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent EnterpriseRISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent Enterprise
Srikant77
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Mind IT Systems
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
vrstrong314
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
Cyanic lab
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
IES VE
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
WSO2
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
Globus
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Globus
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
Tier1 app
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Natan Silnitsky
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
Ortus Solutions, Corp
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
abdulrafaychaudhry
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdfEnhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Jay Das
 

Recently uploaded (20)

RISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent EnterpriseRISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent Enterprise
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdfEnhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
 

Backbone 4.0

  • 2. Introduction What? Backbone.js Why? Web Applications Demand Whom? Beginners to Intermediate *Beginners => Basic JS + Jquery
  • 3. Plan Day 1: 1.5 hrs JS concepts + Jquery + Underscore library 1.5 hrs Basic Elements of Backbone Day 2: 1 hr Example with Backbone - Local Storage 1 hr Example with Backbone - Persistance 1 hr Boilerplate, RequireJS
  • 4. Goal Understading the necessity of MV* Framework Understanding the basic elements of Backbone Overview on designing web app with backbone Sharing experience / knowledge
  • 5. Resources / Books ● http://backbonejs.org/ ● http://addyosmani.github.io/backbone-fundame ntals/ ● Javascript The Good Parts – Douglas Crockford ● https://developer.mozilla.org/en/Learn/JavaScr ipt
  • 6. Practice http://jsfiddle.net/ ● jquery 2.1.0 ● https://cdnjs.cloudflare.com/ajax/libs/json2/20140204/json2.min.js ● https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.2/underscore- min.js ● https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.1.2/backbone-min.js
  • 7. Backbone.js ● Author - Jeremy Ashkenas ● Stable Release - 1.1.2 ● License - MIT ● http://backbonejs.org/ ● Dependency Underscore.js -> http://underscorejs.org/
  • 9. Testimonials ● Digg ● LinkedIn Mobile ● Bit Torrent ● Wordpress ● Documentcloud
  • 10. MVC -Design Pattern Image Source - http://addyosmani.github.io/backbone-fundamentals/
  • 11. JS OOP Basics- DataTypes ● Numbers, ● Strings, ● Booleans, ● null, ● undefined ● Objects ( arrays, functions, regex, objects)
  • 12. JS OOP Basics - Object ● Objects in JavaScript are class-free. ● Prototypal programing language ● http://jsfiddle.net/kbalavignesh/4m8kc6gv/
  • 13. JS OOP Basics -Reference ● Objects are passed around by reference. They are never copied. ● http://jsfiddle.net/kbalavignesh/d5g5k0tL/
  • 14. JS OOP Basics- Prototype ● Object.prototype - an object that comes standard with JavaScript. ● http://jsfiddle.net/kbalavignesh/rp68Ln5s/ ● Delegation
  • 15. JS OOP Basics - Global abatement ● http://jsfiddle.net/kbalavignesh/s6njz5wz/
  • 16. JS OOP Basics - Functions ● Functions in JavaScript are objects. ● Function objects are linked to Function.prototype (which is itself linked to Object.prototype ). ● http://jsfiddle.net/kbalavignesh/a92f3aos/
  • 17. JS OOP Basics -Closure ● A closure is a function having access to the parent scope, even after the parent function has closed. ● http://jsfiddle.net/kbalavignesh/xq5qmz9n/
  • 18. JS OOP Basics -Arrays ● Array.prototype var empty = []; var numbers = ['one', 'two']; console.log(empty.length); console.log(numbers.length);
  • 19. Underscore.js ● forEach - iterate over collections ● sortBy() - sort a collection on a specific attribute ● map() - iterate through a collection, mapping each value through a transformation function ● pluck() - extract a specific attribute ● size() - return the size of a collection ● isEmpty()- determine whether a collection is empty ● groupBy()- group a collection into groups of like items ● pick() - extract a set of attributes from a model ● omit() - extract all attributes from a model except those listed ● keys() and values() - get lists of attribute names and values ● pairs() - get list of attributes as [key, value] pairs ● http://jsfiddle.net/kbalavignesh/ujq80qm3/20/
  • 20. Underscore -Micro Template ● pre compiled templates ● other template engines Mustache, jQuery-tmpl ● how to select - http://garann.github.io/template-chooser/ ● http://www.2ality.com/2012/06/underscore-templates.html ● http://stackoverflow.com/questions/13536262/what-is-javascript-template- precompiling
  • 21. Backbone Basic Elements ● Model ● Collections ● View ● Router ● Events
  • 22. Model ● Holds the attributes ● Takes care of Validation ● Persistance ● Announces updates ● id, idAttribute, cid ● Default, set, get values - https://jsfiddle.net/kbalavignesh/ujq80qm3/9/ ● Change Event - https://jsfiddle.net/kbalavignesh/ujq80qm3/10/ ● Validation - http://jsfiddle.net/kbalavignesh/ujq80qm3/11/ ● Complete Validation - http://jsfiddle.net/kbalavignesh/ujq80qm3/12/
  • 23. Collection ● Holds models ● Announces add/remove/reset/update model ● Collection - http://jsfiddle.net/kbalavignesh/ujq80qm3/13/ ● Collection get by id - http://jsfiddle.net/kbalavignesh/ujq80qm3/14/ ● Collection events - http://jsfiddle.net/kbalavignesh/ujq80qm3/15/ ● Collection with underscore functions - http://jsfiddle.net/kbalavignesh/ujq80qm3/16/ ● Collection sort functions - http://jsfiddle.net/kbalavignesh/ujq80qm3/17/
  • 24. Persistance ● Collection.fetch() => HTTP GET ● Model.save() => HTTP PUT (for existing model) ● Model.save() => HTTP POST (for new model) ● Model.destroy() => HTTP DELETE ● model.save(attrs, {patch: true}) => HTTP PATCH
  • 25. Event ● Event within object - http://jsfiddle.net/kbalavignesh/ujq80qm3/18/ ● Event across objects - http://jsfiddle.net/kbalavignesh/ujq80qm3/19/
  • 26. View ● Logic to present model ● el - el is basically a reference to a DOM element and all views must have one
  • 27. Router & History ● Bookmark ● To Share the link ● To enable backbutton http://backbonetutorials.com/what-is-a-router/#/route/action
  • 28. Local Storage - HTML5 ● Local storage within browser ● Alternative to cookies ● Can save atleast 5MB ● Stored per domain localStorage.setItem("name", "Bala"); localStorage.getItem("name"); localStorage.removeItem("name"); http://www.w3schools.com/html/html5_webstorage.asp
  • 29. TODO List - Example ● Demo - http://backbonejs.org/examples/todos/ ● ToDo Examples for all Framework - http://todomvc.com/ ● Explanation - http://backbonejs.org/docs/todos.html