SlideShare a Scribd company logo
Renan Carvalho 
Carioca 
U2 fan 
Frustrated musician 
Beer Appreciator 
King of age of empires 
Love agile methods 
Front end developer at Chute 
Blog : rcarvalhojs.com 
Github : renancarvalho 
Twitter : rcarvalhojs 
Hate who says bad things about JS
The examples will be based on blogMv project 
https://github.com/blogmv/backbone-browserify 
More info http://blogmv.github.io
What’s the problem? 
What’s backbone? 
Keep data synchronized 
Complex code 
Spaghetti code 
Manage callbacks 
Ajax, XHR? (Impossible to remember the syntax) 
How to test it? :( - TDD? http://www.tddunlocked.com.br/
“Backbone is a mindset change.” 
Renan Carvalho 
What’s backbone?
And it’s also… 
Javascript library 
Based on MV* concept 
Lightweight (production version has 6.5kb) 
Depends on underscore 
Trust me, it’s awesome! 
What’s backbone?
What are you building?
A Helicopter…
…or a Helicopter?
For complex users interface 
Reusable code 
Build single page apps 
When you don’t know what kind of “helicopter” 
When to use? 
When to use it? 
Complex systems 
Good Integration with legacy code 
Simple systems 
Really performatic system 
If you’re under 18 
(Flying lollipop)
Router 
Url routing using (#home or /home) 
Application history
Backbone router 
Router.js
Backbone.history.start(), to start to track url (hashChanges) 
If you’d like to use html5 push state, just use Backbone.history.start({pushState: true}) 
Backbone router 
More examples : http://backbonejs.org/#Router
View 
Represents models data 
Handle user interaction (input events)
View 
render() - Convenction function for render view. Be 
careful with SRP 
el - Dom object, that will be used as the view reference 
(default is a <div>) 
$el - Jquery object that keeps the reference to el. 
initialize() - “Constructor” function for every backbone 
class 
events - Handle view events like ( click, change…) 
Backbone view
postComment.hbs 
Backbone view
postComment.js 
Backbone view
Example of bad 
implementation 
Backbone view
Example of good implementation 
Backbone view
Model 
Manage data. 
Validate data 
know where to send/get data 
Should be thin and beautiful
Model 
fetch() - get data from server 
save() - post/put data on server 
If the model has an id attribute, backbone will perform a put. 
get/set - get/set attributes on model 
parse - function called before backbone merge the server content with the model. 
validate - perform custom validations on model. Fired when save(), set or invoked. 
url - server endpoint (api), where model will perform the request 
More about backbone models: http://backbonejs.org/#Model 
Backbone model
Example of bad 
implementation 
Backbone model
comment.js 
Backbone model
Collection 
Basically “a lot of models 
together"
Collection 
fetch() - Exactly like model, get data from server. 
create() - Create a new model instance within a collection (save on 
server). 
push() - add a model at the end of the collection 
add - add a model into a collection, you can specify the position where 
the model will be added ( this.collection.add(new model(), {at : 8}); ) 
reset() - sets the collection with an array of models. 
More about backbone collection: http://backbonejs.org/#Collection 
Backbone collection
comment.js 
Backbone collection 
article.js
Events 
NOT CALLBACKS !!
Catalog of Events 
Backbone events
listenTo - Tell an object to listen to a particular event 
on another object. 
on - Bind a callback function to an object. 
stopListening - Tell an object to stop listening to 
events. 
Backbone events
Events on model 
Backbone events
Events on collection 
Backbone events
Events on View 
Backbone events
Trigger you own event 
Backbone events 
This way you can unbind the function 
to the object using “off"
Obrigado!

More Related Content

What's hot

Coffeescript: An Opinionated Introduction
Coffeescript: An Opinionated IntroductionCoffeescript: An Opinionated Introduction
Coffeescript: An Opinionated Introduction
Joe Fleming
 
ECSをやろうとしました
ECSをやろうとしましたECSをやろうとしました
ECSをやろうとしました
晋也 古渡
 
HTML5 tutorial: canvas, offfline & sockets
HTML5 tutorial: canvas, offfline & socketsHTML5 tutorial: canvas, offfline & sockets
HTML5 tutorial: canvas, offfline & sockets
Remy Sharp
 
Java Stammtisch Würzburg - CONAIR
Java Stammtisch Würzburg - CONAIRJava Stammtisch Würzburg - CONAIR
Java Stammtisch Würzburg - CONAIR
Matthias Reining
 
Capistrano - automate all the things
Capistrano - automate all the thingsCapistrano - automate all the things
Capistrano - automate all the things
John Cleary
 
Potential gotchas in making a backbone app
Potential gotchas in making a backbone appPotential gotchas in making a backbone app
Potential gotchas in making a backbone app
Vignesh Nandha Kumar
 
Getting Started with Capistrano
Getting Started with CapistranoGetting Started with Capistrano
Getting Started with Capistrano
LaunchAny
 
Using ArcGIS Server with Ruby on Rails
Using ArcGIS Server with Ruby on RailsUsing ArcGIS Server with Ruby on Rails
Using ArcGIS Server with Ruby on Rails
Dave Bouwman
 
Long Running PHP by Kamil Szymanski
Long Running PHP by Kamil SzymanskiLong Running PHP by Kamil Szymanski
Long Running PHP by Kamil Szymanski
The Business Transformation Network
 
Capistrano
CapistranoCapistrano
Capistrano
Jason Noble
 
No Hugging, No Learning
No Hugging, No LearningNo Hugging, No Learning
No Hugging, No Learning
Olaf Alders
 
Ansible lightning talk at Scale 12
Ansible lightning talk at Scale 12Ansible lightning talk at Scale 12
Ansible lightning talk at Scale 12
Justin Garrison
 
Unleashing the Rails Asset Pipeline
Unleashing the Rails Asset PipelineUnleashing the Rails Asset Pipeline
Unleashing the Rails Asset Pipeline
Kenneth Kalmer
 
Testing MeteorJS using CasperJS
Testing MeteorJS using CasperJSTesting MeteorJS using CasperJS
Testing MeteorJS using CasperJS
Stephan Hochhaus
 
Introducing Revel
Introducing RevelIntroducing Revel
Introducing Revel
Zhebr
 
CoffeeScript presentation
CoffeeScript presentationCoffeeScript presentation
CoffeeScript presentationJohn Lynch
 
Sw install with_without_docker
Sw install with_without_dockerSw install with_without_docker
Sw install with_without_docker
SeongJae Park
 
Getting Started with Puppet on Windows - PuppetConf 2014
Getting Started with Puppet on Windows - PuppetConf 2014Getting Started with Puppet on Windows - PuppetConf 2014
Getting Started with Puppet on Windows - PuppetConf 2014
Puppet
 
CasperJs Enjoy Functional Testing
CasperJs Enjoy Functional TestingCasperJs Enjoy Functional Testing
CasperJs Enjoy Functional Testing
Fabien POMEROL
 
Build your website with awestruct and publish it on the cloud with git
Build your website with awestruct and publish it on the cloud with gitBuild your website with awestruct and publish it on the cloud with git
Build your website with awestruct and publish it on the cloud with gitXavier Coulon
 

What's hot (20)

Coffeescript: An Opinionated Introduction
Coffeescript: An Opinionated IntroductionCoffeescript: An Opinionated Introduction
Coffeescript: An Opinionated Introduction
 
ECSをやろうとしました
ECSをやろうとしましたECSをやろうとしました
ECSをやろうとしました
 
HTML5 tutorial: canvas, offfline & sockets
HTML5 tutorial: canvas, offfline & socketsHTML5 tutorial: canvas, offfline & sockets
HTML5 tutorial: canvas, offfline & sockets
 
Java Stammtisch Würzburg - CONAIR
Java Stammtisch Würzburg - CONAIRJava Stammtisch Würzburg - CONAIR
Java Stammtisch Würzburg - CONAIR
 
Capistrano - automate all the things
Capistrano - automate all the thingsCapistrano - automate all the things
Capistrano - automate all the things
 
Potential gotchas in making a backbone app
Potential gotchas in making a backbone appPotential gotchas in making a backbone app
Potential gotchas in making a backbone app
 
Getting Started with Capistrano
Getting Started with CapistranoGetting Started with Capistrano
Getting Started with Capistrano
 
Using ArcGIS Server with Ruby on Rails
Using ArcGIS Server with Ruby on RailsUsing ArcGIS Server with Ruby on Rails
Using ArcGIS Server with Ruby on Rails
 
Long Running PHP by Kamil Szymanski
Long Running PHP by Kamil SzymanskiLong Running PHP by Kamil Szymanski
Long Running PHP by Kamil Szymanski
 
Capistrano
CapistranoCapistrano
Capistrano
 
No Hugging, No Learning
No Hugging, No LearningNo Hugging, No Learning
No Hugging, No Learning
 
Ansible lightning talk at Scale 12
Ansible lightning talk at Scale 12Ansible lightning talk at Scale 12
Ansible lightning talk at Scale 12
 
Unleashing the Rails Asset Pipeline
Unleashing the Rails Asset PipelineUnleashing the Rails Asset Pipeline
Unleashing the Rails Asset Pipeline
 
Testing MeteorJS using CasperJS
Testing MeteorJS using CasperJSTesting MeteorJS using CasperJS
Testing MeteorJS using CasperJS
 
Introducing Revel
Introducing RevelIntroducing Revel
Introducing Revel
 
CoffeeScript presentation
CoffeeScript presentationCoffeeScript presentation
CoffeeScript presentation
 
Sw install with_without_docker
Sw install with_without_dockerSw install with_without_docker
Sw install with_without_docker
 
Getting Started with Puppet on Windows - PuppetConf 2014
Getting Started with Puppet on Windows - PuppetConf 2014Getting Started with Puppet on Windows - PuppetConf 2014
Getting Started with Puppet on Windows - PuppetConf 2014
 
CasperJs Enjoy Functional Testing
CasperJs Enjoy Functional TestingCasperJs Enjoy Functional Testing
CasperJs Enjoy Functional Testing
 
Build your website with awestruct and publish it on the cloud with git
Build your website with awestruct and publish it on the cloud with gitBuild your website with awestruct and publish it on the cloud with git
Build your website with awestruct and publish it on the cloud with git
 

Viewers also liked

CD Design process
CD Design processCD Design process
CD Design process
sophjanecook
 
Chris Scott current credentials
Chris Scott current credentials Chris Scott current credentials
Chris Scott current credentials Chris Scott
 
Осень зима меню ресторана Moma в центре Рима
Осень зима меню ресторана Moma в центре РимаОсень зима меню ресторана Moma в центре Рима
Осень зима меню ресторана Moma в центре Рима
ristorantemoma
 
Kalkınma Atölyesi - KALKINMAYA KATKI VERENLER PROGRAMI Tanıtım
Kalkınma Atölyesi - KALKINMAYA KATKI VERENLER PROGRAMI TanıtımKalkınma Atölyesi - KALKINMAYA KATKI VERENLER PROGRAMI Tanıtım
Kalkınma Atölyesi - KALKINMAYA KATKI VERENLER PROGRAMI Tanıtım
Kalkınmaya Katkı Verenler
 
Kalkınmaya Katkı Verenler Yayın Setleri her yerde
Kalkınmaya Katkı Verenler Yayın Setleri her yerdeKalkınmaya Katkı Verenler Yayın Setleri her yerde
Kalkınmaya Katkı Verenler Yayın Setleri her yerde
Kalkınmaya Katkı Verenler
 
professional courses, awards, peoples and enterprises evaluations from 2000-2016
professional courses, awards, peoples and enterprises evaluations from 2000-2016professional courses, awards, peoples and enterprises evaluations from 2000-2016
professional courses, awards, peoples and enterprises evaluations from 2000-2016Ricardo Fonseca
 
The sandy hurricane- maria albea
The sandy hurricane- maria albeaThe sandy hurricane- maria albea
The sandy hurricane- maria albea
marialbea
 

Viewers also liked (9)

CD Design process
CD Design processCD Design process
CD Design process
 
Chris Scott current credentials
Chris Scott current credentials Chris Scott current credentials
Chris Scott current credentials
 
Осень зима меню ресторана Moma в центре Рима
Осень зима меню ресторана Moma в центре РимаОсень зима меню ресторана Moma в центре Рима
Осень зима меню ресторана Moma в центре Рима
 
NEWSLETTER
NEWSLETTERNEWSLETTER
NEWSLETTER
 
Kalkınma Atölyesi - KALKINMAYA KATKI VERENLER PROGRAMI Tanıtım
Kalkınma Atölyesi - KALKINMAYA KATKI VERENLER PROGRAMI TanıtımKalkınma Atölyesi - KALKINMAYA KATKI VERENLER PROGRAMI Tanıtım
Kalkınma Atölyesi - KALKINMAYA KATKI VERENLER PROGRAMI Tanıtım
 
Kalkınmaya Katkı Verenler Yayın Setleri her yerde
Kalkınmaya Katkı Verenler Yayın Setleri her yerdeKalkınmaya Katkı Verenler Yayın Setleri her yerde
Kalkınmaya Katkı Verenler Yayın Setleri her yerde
 
professional courses, awards, peoples and enterprises evaluations from 2000-2016
professional courses, awards, peoples and enterprises evaluations from 2000-2016professional courses, awards, peoples and enterprises evaluations from 2000-2016
professional courses, awards, peoples and enterprises evaluations from 2000-2016
 
The sandy hurricane- maria albea
The sandy hurricane- maria albeaThe sandy hurricane- maria albea
The sandy hurricane- maria albea
 
maintenance project
maintenance projectmaintenance project
maintenance project
 

Similar to Backbone the Good Parts

Backbone
BackboneBackbone
Backbone
Glenn De Backer
 
Ruby on Rails survival guide of an aged Java developer
Ruby on Rails survival guide of an aged Java developerRuby on Rails survival guide of an aged Java developer
Ruby on Rails survival guide of an aged Java developer
gicappa
 
Rails 101
Rails 101Rails 101
Intro to Rails Give Camp Atlanta
Intro to Rails Give Camp AtlantaIntro to Rails Give Camp Atlanta
Intro to Rails Give Camp Atlanta
Jason Noble
 
Developing maintainable Cordova applications
Developing maintainable Cordova applicationsDeveloping maintainable Cordova applications
Developing maintainable Cordova applications
Ivano Malavolta
 
Mahout Introduction BarCampDC
Mahout Introduction BarCampDCMahout Introduction BarCampDC
Mahout Introduction BarCampDC
Drew Farris
 
20130528 solution linux_frousseau_nopain_webdev
20130528 solution linux_frousseau_nopain_webdev20130528 solution linux_frousseau_nopain_webdev
20130528 solution linux_frousseau_nopain_webdevFrank Rousseau
 
Developing Java Web Applications
Developing Java Web ApplicationsDeveloping Java Web Applications
Developing Java Web Applications
hchen1
 
Raybiztech Guide To Backbone Javascript Library
Raybiztech Guide To Backbone Javascript LibraryRaybiztech Guide To Backbone Javascript Library
Raybiztech Guide To Backbone Javascript Library
ray biztech
 
Viking academy backbone.js
Viking academy  backbone.jsViking academy  backbone.js
Viking academy backbone.js
Bert Wijnants
 
Sprockets
SprocketsSprockets
Backbone.js
Backbone.jsBackbone.js
Backbone.js
Knoldus Inc.
 
Embulk, an open-source plugin-based parallel bulk data loader
Embulk, an open-source plugin-based parallel bulk data loaderEmbulk, an open-source plugin-based parallel bulk data loader
Embulk, an open-source plugin-based parallel bulk data loader
Sadayuki Furuhashi
 
Single Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and JasmineSingle Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and JasminePaulo Ragonha
 
Sherlock Homepage - A detective story about running large web services (VISUG...
Sherlock Homepage - A detective story about running large web services (VISUG...Sherlock Homepage - A detective story about running large web services (VISUG...
Sherlock Homepage - A detective story about running large web services (VISUG...
Maarten Balliauw
 
Sherlock Homepage (Maarten Balliauw)
Sherlock Homepage (Maarten Balliauw)Sherlock Homepage (Maarten Balliauw)
Sherlock Homepage (Maarten Balliauw)
Visug
 
Plugin-based software design with Ruby and RubyGems
Plugin-based software design with Ruby and RubyGemsPlugin-based software design with Ruby and RubyGems
Plugin-based software design with Ruby and RubyGems
Sadayuki Furuhashi
 
Riak with Rails
Riak with RailsRiak with Rails
Riak with Rails
Sean Cribbs
 
ITT 2015 - Simon Stewart - Building Android Apps at Speed and Scale
ITT 2015 - Simon Stewart - Building Android Apps at Speed and ScaleITT 2015 - Simon Stewart - Building Android Apps at Speed and Scale
ITT 2015 - Simon Stewart - Building Android Apps at Speed and Scale
Istanbul Tech Talks
 

Similar to Backbone the Good Parts (20)

Backbonejs on Rails
Backbonejs on RailsBackbonejs on Rails
Backbonejs on Rails
 
Backbone
BackboneBackbone
Backbone
 
Ruby on Rails survival guide of an aged Java developer
Ruby on Rails survival guide of an aged Java developerRuby on Rails survival guide of an aged Java developer
Ruby on Rails survival guide of an aged Java developer
 
Rails 101
Rails 101Rails 101
Rails 101
 
Intro to Rails Give Camp Atlanta
Intro to Rails Give Camp AtlantaIntro to Rails Give Camp Atlanta
Intro to Rails Give Camp Atlanta
 
Developing maintainable Cordova applications
Developing maintainable Cordova applicationsDeveloping maintainable Cordova applications
Developing maintainable Cordova applications
 
Mahout Introduction BarCampDC
Mahout Introduction BarCampDCMahout Introduction BarCampDC
Mahout Introduction BarCampDC
 
20130528 solution linux_frousseau_nopain_webdev
20130528 solution linux_frousseau_nopain_webdev20130528 solution linux_frousseau_nopain_webdev
20130528 solution linux_frousseau_nopain_webdev
 
Developing Java Web Applications
Developing Java Web ApplicationsDeveloping Java Web Applications
Developing Java Web Applications
 
Raybiztech Guide To Backbone Javascript Library
Raybiztech Guide To Backbone Javascript LibraryRaybiztech Guide To Backbone Javascript Library
Raybiztech Guide To Backbone Javascript Library
 
Viking academy backbone.js
Viking academy  backbone.jsViking academy  backbone.js
Viking academy backbone.js
 
Sprockets
SprocketsSprockets
Sprockets
 
Backbone.js
Backbone.jsBackbone.js
Backbone.js
 
Embulk, an open-source plugin-based parallel bulk data loader
Embulk, an open-source plugin-based parallel bulk data loaderEmbulk, an open-source plugin-based parallel bulk data loader
Embulk, an open-source plugin-based parallel bulk data loader
 
Single Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and JasmineSingle Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and Jasmine
 
Sherlock Homepage - A detective story about running large web services (VISUG...
Sherlock Homepage - A detective story about running large web services (VISUG...Sherlock Homepage - A detective story about running large web services (VISUG...
Sherlock Homepage - A detective story about running large web services (VISUG...
 
Sherlock Homepage (Maarten Balliauw)
Sherlock Homepage (Maarten Balliauw)Sherlock Homepage (Maarten Balliauw)
Sherlock Homepage (Maarten Balliauw)
 
Plugin-based software design with Ruby and RubyGems
Plugin-based software design with Ruby and RubyGemsPlugin-based software design with Ruby and RubyGems
Plugin-based software design with Ruby and RubyGems
 
Riak with Rails
Riak with RailsRiak with Rails
Riak with Rails
 
ITT 2015 - Simon Stewart - Building Android Apps at Speed and Scale
ITT 2015 - Simon Stewart - Building Android Apps at Speed and ScaleITT 2015 - Simon Stewart - Building Android Apps at Speed and Scale
ITT 2015 - Simon Stewart - Building Android Apps at Speed and Scale
 

Recently uploaded

Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke
 
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
 
Strategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptxStrategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptx
varshanayak241
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 
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
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 
Why React Native as a Strategic Advantage for Startup Innovation.pdf
Why React Native as a Strategic Advantage for Startup Innovation.pdfWhy React Native as a Strategic Advantage for Startup Innovation.pdf
Why React Native as a Strategic Advantage for Startup Innovation.pdf
ayushiqss
 
Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web Services
KrzysztofKkol1
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Shahin Sheidaei
 
Visitor Management System in India- Vizman.app
Visitor Management System in India- Vizman.appVisitor Management System in India- Vizman.app
Visitor Management System in India- Vizman.app
NaapbooksPrivateLimi
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
Georgi Kodinov
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
wottaspaceseo
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Globus
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
Tier1 app
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Anthony Dahanne
 

Recently uploaded (20)

Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
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
 
Strategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptxStrategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptx
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
Why React Native as a Strategic Advantage for Startup Innovation.pdf
Why React Native as a Strategic Advantage for Startup Innovation.pdfWhy React Native as a Strategic Advantage for Startup Innovation.pdf
Why React Native as a Strategic Advantage for Startup Innovation.pdf
 
Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web Services
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
 
Visitor Management System in India- Vizman.app
Visitor Management System in India- Vizman.appVisitor Management System in India- Vizman.app
Visitor Management System in India- Vizman.app
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
 

Backbone the Good Parts

  • 1.
  • 2. Renan Carvalho Carioca U2 fan Frustrated musician Beer Appreciator King of age of empires Love agile methods Front end developer at Chute Blog : rcarvalhojs.com Github : renancarvalho Twitter : rcarvalhojs Hate who says bad things about JS
  • 3. The examples will be based on blogMv project https://github.com/blogmv/backbone-browserify More info http://blogmv.github.io
  • 4. What’s the problem? What’s backbone? Keep data synchronized Complex code Spaghetti code Manage callbacks Ajax, XHR? (Impossible to remember the syntax) How to test it? :( - TDD? http://www.tddunlocked.com.br/
  • 5. “Backbone is a mindset change.” Renan Carvalho What’s backbone?
  • 6. And it’s also… Javascript library Based on MV* concept Lightweight (production version has 6.5kb) Depends on underscore Trust me, it’s awesome! What’s backbone?
  • 7. What are you building?
  • 10. For complex users interface Reusable code Build single page apps When you don’t know what kind of “helicopter” When to use? When to use it? Complex systems Good Integration with legacy code Simple systems Really performatic system If you’re under 18 (Flying lollipop)
  • 11. Router Url routing using (#home or /home) Application history
  • 13. Backbone.history.start(), to start to track url (hashChanges) If you’d like to use html5 push state, just use Backbone.history.start({pushState: true}) Backbone router More examples : http://backbonejs.org/#Router
  • 14. View Represents models data Handle user interaction (input events)
  • 15. View render() - Convenction function for render view. Be careful with SRP el - Dom object, that will be used as the view reference (default is a <div>) $el - Jquery object that keeps the reference to el. initialize() - “Constructor” function for every backbone class events - Handle view events like ( click, change…) Backbone view
  • 18. Example of bad implementation Backbone view
  • 19. Example of good implementation Backbone view
  • 20. Model Manage data. Validate data know where to send/get data Should be thin and beautiful
  • 21. Model fetch() - get data from server save() - post/put data on server If the model has an id attribute, backbone will perform a put. get/set - get/set attributes on model parse - function called before backbone merge the server content with the model. validate - perform custom validations on model. Fired when save(), set or invoked. url - server endpoint (api), where model will perform the request More about backbone models: http://backbonejs.org/#Model Backbone model
  • 22. Example of bad implementation Backbone model
  • 24. Collection Basically “a lot of models together"
  • 25. Collection fetch() - Exactly like model, get data from server. create() - Create a new model instance within a collection (save on server). push() - add a model at the end of the collection add - add a model into a collection, you can specify the position where the model will be added ( this.collection.add(new model(), {at : 8}); ) reset() - sets the collection with an array of models. More about backbone collection: http://backbonejs.org/#Collection Backbone collection
  • 28. Catalog of Events Backbone events
  • 29. listenTo - Tell an object to listen to a particular event on another object. on - Bind a callback function to an object. stopListening - Tell an object to stop listening to events. Backbone events
  • 30. Events on model Backbone events
  • 31. Events on collection Backbone events
  • 32. Events on View Backbone events
  • 33. Trigger you own event Backbone events This way you can unbind the function to the object using “off"