SlideShare a Scribd company logo
1 of 143
Single Page Application
     Development with
backbone.js and Simple.Web
          Chris Canal
Who am I?
•   Senior Developer at StormID
•   Developed our in-house SDK
•   Does too much Umbraco
•   Trying to stop my boss from crazy
•   Being opinionated
•   Been doing this for too long, 11 years!
•   Crap at making PowerPoint presentations
•   Probably wrong 90% of the time, so
    please correct me when I made a stupid
    comment
Agenda
• Introduction
• Backbone
   •   Backbone Marionette
   •   Underscore
   •   Handlebars
   •   RequireJS
• Simple.Web
Single Page Applications
Single Page Application?
• A software application
• On a single web page
• Pretty much exactly what it says on the tin, if it came in a tin
Gmail
mail.google.com
Twitter
twitter.com
Facebook
facebook.com
Spin
spin.com
A Quick Web App History
Web 1.0

          GET

                Webserver
Web 1.0
          GET




          GET   Webserver
AJAX, BOOYA
AJAX (Web 2.0?)
                  GET




                  GET   Webserver
AJAX (Web 2.0?)
                  GET




                  GET   Webserver
AJAX (Web 2.0?)
                  GET




                  GET   API
  Application
MV*
MV*
• MVPresenter
• MVController
• MVPresentationModel
• MVViewModel
• MVHandler
Serverside MV*
Small Talk
First implentation of MVC
Ruby on Rails
MVC
Cake PHP
MVC
WebForms
Wut?
Castle Monorail
MVC
ASP.NET MVC
MVC
FubuMVC
MVC
Simple.Web
MVHandler
Simple.Web
Conventions &
Structure
Clientside MV*
YUI
Ember JS
Knockout
AngularJS
Backbone.js
Backbone.js
What is it?
• Event driven MV* Framework
Annotated Source
Github
Who uses Backbone.js?
• Hulu
• Foursquare
• Stripe
• Khan Academy
• Wordpress.com
• Many more…
Code Structure
• Events
• Models
• Collections
• Views
• Router
Events
on
off
trigger
on
off
trigger
Beware memory leaks!
Event Types
• add – model, collection
• remove – model, collection
• reset – collection
• change – model, options
• change:[attribute] – model, value, options
• destroy – model, collection
• sync – model, collection
• route:[name] – router
• all
Models
extend
constructor/initialize
url/urlRoot
defaults
get/set
validate
toJSON
State!
save
and more…
extend
extend
Overriding base methods
constructor/initialize
initialize
url/urlRoot
defaults
get/set
validate
toJSON
State!
save
More!
Collections
model
url
create
add
get
where
fetch
reset
and more…
model
url
create
add
get
where
fetch
reset
More!
Views
el/tagName/$el
render
remove
events
el/tagName/$el
render
remove
events
router
routes
Route
navigate
History
routes
route
navigate
Demo?
Questions?
Backbone Marionette
What is it?
Application Library for Backbone
What does it give you?
• Backbone.Marionette.Application
• Backbone.Marionette.AppRouter
• Backbone.Marionette.ItemView
• Backbone.Marionette.CollectionView
• Backbone.Marionette.EventAggregator
• And more…
Backbone.Marionet
te.Application
Starting An Application
events
addInitializer
regions
Starting
events
addInitializer
regions
Backbone.Marionet
te.AppRouter
controller
controller
Backbone.Marionett
e.ItemView
on*
events
serializeData
On*
events
serializeData
Backbone.Marionett
e.CollectionView
itemView
emptyView
on*
events
itemView
emptyView
on*
events
Backbone.Marionett
e.EventAggregator
Demo?
Questions?
Underscore
What is it?
Batman utility belt
Handlebars
What is it?
Mustache templating implemetation
Basic
Compiling
Using it with Backbone.Marionette
RequireJS
What is it?
Clientside Dependency Management
AMD/CommonJS implentation
What does it give you?
• Dependency Management
Config
Config
require()
define()
Text plugin
Using it with Backbone.Marionette
r.js
What is it?
• Combines related scripts together into build layers and minifies them
  via UglifyJS
• Optimizes CSS by inlining CSS files referenced by @import and
  removing comments.
Getting it…
• You have Node.js installed, yea?
• npm install –g requires
• node r.js path/tp/buildscript.js
Config
Config
Demo?
Questions?
Simple.Web
What is it?
SOLID Driven RESTful web framework
Model-View-Hander
What does it give you?
• Proper Separation on Concerns – One class per action
• Easily Testable
• SOLID Compliant
Interfaces
• IGet
• IPost
• IPost<T>
• IDelete
• IPut
• IPut<T>
• IOutput
• And more…
IGet
IPost
IPost<T>
IDelete
IPut<T>
IOutput<T>
Demo
Wiring it all up!
Questions?
Resources
• http://backbonetraining.net/resources Loads of Backbone resources
• https://github.com/markrendle/Simple.Web
• http://blog.markrendle.net/2012/06/01/simple-web/
Thanks!

More Related Content

What's hot

Single page application
Single page applicationSingle page application
Single page applicationArthur Fung
 
Making Single Page Applications (SPA) faster
Making Single Page Applications (SPA) faster Making Single Page Applications (SPA) faster
Making Single Page Applications (SPA) faster Boris Livshutz
 
Single page applications
Single page applicationsSingle page applications
Single page applicationsDiego Cardozo
 
Web technologies practical guide
Web technologies practical guideWeb technologies practical guide
Web technologies practical guidesamir azazy
 
Building WordPress sites with AngularJS and the RESTful plugin JSON API
Building WordPress sites with AngularJS and the RESTful plugin JSON APIBuilding WordPress sites with AngularJS and the RESTful plugin JSON API
Building WordPress sites with AngularJS and the RESTful plugin JSON APIEric Greene
 
Building WordPress sites with AngularJS and the RESTful plugin JSON API @ Dev...
Building WordPress sites with AngularJS and the RESTful plugin JSON API @ Dev...Building WordPress sites with AngularJS and the RESTful plugin JSON API @ Dev...
Building WordPress sites with AngularJS and the RESTful plugin JSON API @ Dev...Eric Greene
 
single page application
single page applicationsingle page application
single page applicationRavindra K
 
Getting SEO performance in Angular Meteor with ngmeta
Getting SEO performance in Angular Meteor with ngmetaGetting SEO performance in Angular Meteor with ngmeta
Getting SEO performance in Angular Meteor with ngmetaWill Haire
 
Using WordPress as a Headless CMS
Using WordPress as a Headless CMSUsing WordPress as a Headless CMS
Using WordPress as a Headless CMSAdam Rasheed
 
Modern Applications With Asp.net Core 5 and Vue JS 3
Modern Applications With Asp.net Core 5 and Vue JS 3Modern Applications With Asp.net Core 5 and Vue JS 3
Modern Applications With Asp.net Core 5 and Vue JS 3Alexandre Malavasi
 
Single Page Application presentation
Single Page Application presentationSingle Page Application presentation
Single Page Application presentationJohn Staveley
 
Using MAMP for Web Development
Using MAMP for Web DevelopmentUsing MAMP for Web Development
Using MAMP for Web DevelopmentEric Greene
 
WebAssembly in Houdini CSS, is it possible?
WebAssembly in Houdini CSS, is it possible?WebAssembly in Houdini CSS, is it possible?
WebAssembly in Houdini CSS, is it possible?Alexandr Skachkov
 
Host, deploy & scale Blazor Server Apps
Host, deploy & scale Blazor Server AppsHost, deploy & scale Blazor Server Apps
Host, deploy & scale Blazor Server AppsJose Javier Columbie
 

What's hot (20)

Single page application
Single page applicationSingle page application
Single page application
 
Making Single Page Applications (SPA) faster
Making Single Page Applications (SPA) faster Making Single Page Applications (SPA) faster
Making Single Page Applications (SPA) faster
 
Single page applications
Single page applicationsSingle page applications
Single page applications
 
Web technologies practical guide
Web technologies practical guideWeb technologies practical guide
Web technologies practical guide
 
Single page App
Single page AppSingle page App
Single page App
 
A Gentle Introduction to Blazor
A Gentle Introduction to BlazorA Gentle Introduction to Blazor
A Gentle Introduction to Blazor
 
Building WordPress sites with AngularJS and the RESTful plugin JSON API
Building WordPress sites with AngularJS and the RESTful plugin JSON APIBuilding WordPress sites with AngularJS and the RESTful plugin JSON API
Building WordPress sites with AngularJS and the RESTful plugin JSON API
 
Building WordPress sites with AngularJS and the RESTful plugin JSON API @ Dev...
Building WordPress sites with AngularJS and the RESTful plugin JSON API @ Dev...Building WordPress sites with AngularJS and the RESTful plugin JSON API @ Dev...
Building WordPress sites with AngularJS and the RESTful plugin JSON API @ Dev...
 
Jquery
JqueryJquery
Jquery
 
single page application
single page applicationsingle page application
single page application
 
Getting SEO performance in Angular Meteor with ngmeta
Getting SEO performance in Angular Meteor with ngmetaGetting SEO performance in Angular Meteor with ngmeta
Getting SEO performance in Angular Meteor with ngmeta
 
Using WordPress as a Headless CMS
Using WordPress as a Headless CMSUsing WordPress as a Headless CMS
Using WordPress as a Headless CMS
 
Modern Applications With Asp.net Core 5 and Vue JS 3
Modern Applications With Asp.net Core 5 and Vue JS 3Modern Applications With Asp.net Core 5 and Vue JS 3
Modern Applications With Asp.net Core 5 and Vue JS 3
 
Single Page Application presentation
Single Page Application presentationSingle Page Application presentation
Single Page Application presentation
 
Using MAMP for Web Development
Using MAMP for Web DevelopmentUsing MAMP for Web Development
Using MAMP for Web Development
 
WebAssembly in Houdini CSS, is it possible?
WebAssembly in Houdini CSS, is it possible?WebAssembly in Houdini CSS, is it possible?
WebAssembly in Houdini CSS, is it possible?
 
Codegen2021 blazor mobile
Codegen2021 blazor mobileCodegen2021 blazor mobile
Codegen2021 blazor mobile
 
Host, deploy & scale Blazor Server Apps
Host, deploy & scale Blazor Server AppsHost, deploy & scale Blazor Server Apps
Host, deploy & scale Blazor Server Apps
 
Javascript & Jquery
Javascript & JqueryJavascript & Jquery
Javascript & Jquery
 
Introduction to web development
Introduction to web developmentIntroduction to web development
Introduction to web development
 

Viewers also liked

Single-Page Application Design Principles 101
Single-Page Application Design Principles 101Single-Page Application Design Principles 101
Single-Page Application Design Principles 101Jollen Chen
 
Single Page Application (SPA) using AngularJS
Single Page Application (SPA) using AngularJSSingle Page Application (SPA) using AngularJS
Single Page Application (SPA) using AngularJSM R Rony
 
Secrets of Awesome JavaScript API Design
Secrets of Awesome JavaScript API DesignSecrets of Awesome JavaScript API Design
Secrets of Awesome JavaScript API DesignBrandon Satrom
 
Axr betabeers 2011-01-31
Axr betabeers 2011-01-31Axr betabeers 2011-01-31
Axr betabeers 2011-01-31Miro Keller
 
How to push a react js application in production and sleep better
How to push a react js application in production and sleep betterHow to push a react js application in production and sleep better
How to push a react js application in production and sleep betterEmanuele Rampichini
 
RxJS 5 in Depth
RxJS 5 in DepthRxJS 5 in Depth
RxJS 5 in DepthC4Media
 
Single Page Application Best practices
Single Page Application Best practicesSingle Page Application Best practices
Single Page Application Best practicesTarence DSouza
 
5 single page application principles developers need to know
5 single page application principles developers need to know5 single page application principles developers need to know
5 single page application principles developers need to knowChris Love
 
Refactoring to a Single Page Application
Refactoring to a Single Page ApplicationRefactoring to a Single Page Application
Refactoring to a Single Page ApplicationCodemotion
 
Five stages of grief: Evolving a multi-page web app to a single page application
Five stages of grief: Evolving a multi-page web app to a single page applicationFive stages of grief: Evolving a multi-page web app to a single page application
Five stages of grief: Evolving a multi-page web app to a single page applicationCharles Knight
 
Single Page WebApp Architecture
Single Page WebApp ArchitectureSingle Page WebApp Architecture
Single Page WebApp ArchitectureMorgan Cheng
 
Vue 2.0 + Vuex Router & Vuex at Vue.js
Vue 2.0 + Vuex Router & Vuex at Vue.jsVue 2.0 + Vuex Router & Vuex at Vue.js
Vue 2.0 + Vuex Router & Vuex at Vue.jsTakuya Tejima
 
AngularJS Security: defend your Single Page Application
AngularJS Security: defend your Single Page Application AngularJS Security: defend your Single Page Application
AngularJS Security: defend your Single Page Application Carlo Bonamico
 
How to Build SPA with Vue Router 2.0
How to Build SPA with Vue Router 2.0How to Build SPA with Vue Router 2.0
How to Build SPA with Vue Router 2.0Takuya Tejima
 
How to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your NicheHow to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your NicheLeslie Samuel
 

Viewers also liked (17)

Single-Page Application Design Principles 101
Single-Page Application Design Principles 101Single-Page Application Design Principles 101
Single-Page Application Design Principles 101
 
Single Page Application (SPA) using AngularJS
Single Page Application (SPA) using AngularJSSingle Page Application (SPA) using AngularJS
Single Page Application (SPA) using AngularJS
 
Introduction to Angularjs
Introduction to AngularjsIntroduction to Angularjs
Introduction to Angularjs
 
Secrets of Awesome JavaScript API Design
Secrets of Awesome JavaScript API DesignSecrets of Awesome JavaScript API Design
Secrets of Awesome JavaScript API Design
 
Axr betabeers 2011-01-31
Axr betabeers 2011-01-31Axr betabeers 2011-01-31
Axr betabeers 2011-01-31
 
How to push a react js application in production and sleep better
How to push a react js application in production and sleep betterHow to push a react js application in production and sleep better
How to push a react js application in production and sleep better
 
RxJS 5 in Depth
RxJS 5 in DepthRxJS 5 in Depth
RxJS 5 in Depth
 
Single Page Application Best practices
Single Page Application Best practicesSingle Page Application Best practices
Single Page Application Best practices
 
5 single page application principles developers need to know
5 single page application principles developers need to know5 single page application principles developers need to know
5 single page application principles developers need to know
 
Refactoring to a Single Page Application
Refactoring to a Single Page ApplicationRefactoring to a Single Page Application
Refactoring to a Single Page Application
 
Five stages of grief: Evolving a multi-page web app to a single page application
Five stages of grief: Evolving a multi-page web app to a single page applicationFive stages of grief: Evolving a multi-page web app to a single page application
Five stages of grief: Evolving a multi-page web app to a single page application
 
Love at first Vue
Love at first VueLove at first Vue
Love at first Vue
 
Single Page WebApp Architecture
Single Page WebApp ArchitectureSingle Page WebApp Architecture
Single Page WebApp Architecture
 
Vue 2.0 + Vuex Router & Vuex at Vue.js
Vue 2.0 + Vuex Router & Vuex at Vue.jsVue 2.0 + Vuex Router & Vuex at Vue.js
Vue 2.0 + Vuex Router & Vuex at Vue.js
 
AngularJS Security: defend your Single Page Application
AngularJS Security: defend your Single Page Application AngularJS Security: defend your Single Page Application
AngularJS Security: defend your Single Page Application
 
How to Build SPA with Vue Router 2.0
How to Build SPA with Vue Router 2.0How to Build SPA with Vue Router 2.0
How to Build SPA with Vue Router 2.0
 
How to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your NicheHow to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your Niche
 

Similar to Single Page Application Development with backbone.js and Simple.Web

JavaScript in Universal Windows Platform apps
JavaScript in Universal Windows Platform appsJavaScript in Universal Windows Platform apps
JavaScript in Universal Windows Platform appsTimmy Kokke
 
【前端Mvc】mvc behind-alphatown
【前端Mvc】mvc behind-alphatown【前端Mvc】mvc behind-alphatown
【前端Mvc】mvc behind-alphatowntaobao.com
 
新版阿尔法城背后的前端MVC实践
新版阿尔法城背后的前端MVC实践新版阿尔法城背后的前端MVC实践
新版阿尔法城背后的前端MVC实践Dexter Yang
 
Using-AngularJS-with-Sitefinity.pptx
Using-AngularJS-with-Sitefinity.pptxUsing-AngularJS-with-Sitefinity.pptx
Using-AngularJS-with-Sitefinity.pptxkisofe
 
Bootstrapping angular js with bower grunt yeoman
Bootstrapping angular js with bower grunt yeomanBootstrapping angular js with bower grunt yeoman
Bootstrapping angular js with bower grunt yeomanMakarand Bhatambarekar
 
Azure Functions Real World Examples
Azure Functions Real World Examples Azure Functions Real World Examples
Azure Functions Real World Examples Yochay Kiriaty
 
Introduction to web application development with Vue (for absolute beginners)...
Introduction to web application development with Vue (for absolute beginners)...Introduction to web application development with Vue (for absolute beginners)...
Introduction to web application development with Vue (for absolute beginners)...Lucas Jellema
 
Wintellect - Devscovery - Enterprise JavaScript Development 2 of 2
Wintellect - Devscovery - Enterprise JavaScript Development 2 of 2Wintellect - Devscovery - Enterprise JavaScript Development 2 of 2
Wintellect - Devscovery - Enterprise JavaScript Development 2 of 2Jeremy Likness
 
[Blibli Brown Bag] Nodejs - The Other Side of Javascript
[Blibli Brown Bag] Nodejs - The Other Side of Javascript[Blibli Brown Bag] Nodejs - The Other Side of Javascript
[Blibli Brown Bag] Nodejs - The Other Side of JavascriptIrfan Maulana
 
Mvvm knockout vs angular
Mvvm knockout vs angularMvvm knockout vs angular
Mvvm knockout vs angularBasarat Syed
 
How angularjs saves rails
How angularjs saves railsHow angularjs saves rails
How angularjs saves railsMichael He
 
Isomorphic web application
Isomorphic web applicationIsomorphic web application
Isomorphic web applicationOliver N
 
SharePoint Fest Seattle - SharePoint Framework, Angular & Azure Functions
SharePoint Fest Seattle - SharePoint Framework, Angular & Azure FunctionsSharePoint Fest Seattle - SharePoint Framework, Angular & Azure Functions
SharePoint Fest Seattle - SharePoint Framework, Angular & Azure FunctionsSébastien Levert
 
Rapid development with Rails
Rapid development with RailsRapid development with Rails
Rapid development with RailsYi-Ting Cheng
 
Introduction to Ember.js and how we used it at FlowPro.io
Introduction to Ember.js and how we used it at FlowPro.ioIntroduction to Ember.js and how we used it at FlowPro.io
Introduction to Ember.js and how we used it at FlowPro.ioPaul Knittel
 
Sugarcoating your frontend one ViewModel at a time
Sugarcoating your frontend one ViewModel at a timeSugarcoating your frontend one ViewModel at a time
Sugarcoating your frontend one ViewModel at a timeEinar Ingebrigtsen
 

Similar to Single Page Application Development with backbone.js and Simple.Web (20)

JavaScript in Universal Windows Platform apps
JavaScript in Universal Windows Platform appsJavaScript in Universal Windows Platform apps
JavaScript in Universal Windows Platform apps
 
【前端Mvc】mvc behind-alphatown
【前端Mvc】mvc behind-alphatown【前端Mvc】mvc behind-alphatown
【前端Mvc】mvc behind-alphatown
 
新版阿尔法城背后的前端MVC实践
新版阿尔法城背后的前端MVC实践新版阿尔法城背后的前端MVC实践
新版阿尔法城背后的前端MVC实践
 
Wheel.js
Wheel.jsWheel.js
Wheel.js
 
Titanium Alloy Tutorial
Titanium Alloy TutorialTitanium Alloy Tutorial
Titanium Alloy Tutorial
 
Using-AngularJS-with-Sitefinity.pptx
Using-AngularJS-with-Sitefinity.pptxUsing-AngularJS-with-Sitefinity.pptx
Using-AngularJS-with-Sitefinity.pptx
 
Bootstrapping angular js with bower grunt yeoman
Bootstrapping angular js with bower grunt yeomanBootstrapping angular js with bower grunt yeoman
Bootstrapping angular js with bower grunt yeoman
 
Azure Functions Real World Examples
Azure Functions Real World Examples Azure Functions Real World Examples
Azure Functions Real World Examples
 
Introduction to web application development with Vue (for absolute beginners)...
Introduction to web application development with Vue (for absolute beginners)...Introduction to web application development with Vue (for absolute beginners)...
Introduction to web application development with Vue (for absolute beginners)...
 
Wintellect - Devscovery - Enterprise JavaScript Development 2 of 2
Wintellect - Devscovery - Enterprise JavaScript Development 2 of 2Wintellect - Devscovery - Enterprise JavaScript Development 2 of 2
Wintellect - Devscovery - Enterprise JavaScript Development 2 of 2
 
Introduction to Flask Micro Framework
Introduction to Flask Micro FrameworkIntroduction to Flask Micro Framework
Introduction to Flask Micro Framework
 
[Blibli Brown Bag] Nodejs - The Other Side of Javascript
[Blibli Brown Bag] Nodejs - The Other Side of Javascript[Blibli Brown Bag] Nodejs - The Other Side of Javascript
[Blibli Brown Bag] Nodejs - The Other Side of Javascript
 
Mvvm knockout vs angular
Mvvm knockout vs angularMvvm knockout vs angular
Mvvm knockout vs angular
 
How angularjs saves rails
How angularjs saves railsHow angularjs saves rails
How angularjs saves rails
 
Ember
EmberEmber
Ember
 
Isomorphic web application
Isomorphic web applicationIsomorphic web application
Isomorphic web application
 
SharePoint Fest Seattle - SharePoint Framework, Angular & Azure Functions
SharePoint Fest Seattle - SharePoint Framework, Angular & Azure FunctionsSharePoint Fest Seattle - SharePoint Framework, Angular & Azure Functions
SharePoint Fest Seattle - SharePoint Framework, Angular & Azure Functions
 
Rapid development with Rails
Rapid development with RailsRapid development with Rails
Rapid development with Rails
 
Introduction to Ember.js and how we used it at FlowPro.io
Introduction to Ember.js and how we used it at FlowPro.ioIntroduction to Ember.js and how we used it at FlowPro.io
Introduction to Ember.js and how we used it at FlowPro.io
 
Sugarcoating your frontend one ViewModel at a time
Sugarcoating your frontend one ViewModel at a timeSugarcoating your frontend one ViewModel at a time
Sugarcoating your frontend one ViewModel at a time
 

Single Page Application Development with backbone.js and Simple.Web

Editor's Notes

  1. Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions,views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.When working on a web application that involves a lot of JavaScript, one of the first things you learn is to stop tying your data to the DOM. It&apos;s all too easy to create JavaScript applications that end up as tangled piles of jQuery selectors and callbacks, all trying frantically to keep data in sync between the HTML UI, your JavaScript logic, and the database on your server. For rich client-side applications, a more structured approach is often helpful.With Backbone, you represent your data as Models, which can be created, validated, destroyed, and saved to the server. Whenever a UI action causes an attribute of a model to change, the model triggers a &quot;change&quot; event; all the Views that display the model&apos;s state can be notified of the change, so that they are able to respond accordingly, re-rendering themselves with the new information. In a finished Backbone app, you don&apos;t have to write the glue code that looks into the DOM to find an element with a specific id, and update the HTML manually — when the model changes, the views simply update themselves.
  2. Loading text documents as dependencies