SlideShare a Scribd company logo
Tools that get you laid
      webcamplj 2011
         @swizec
The issue


• want shiny HTML app
• RESTful API’s are expected
• need speed and clean code
• I might want to add features (fast)
Thin server fat client


• server is a fancy database
• servers are not free
• more users? = more computing power!
The tools


• express.js
• underscore.js
• backbone.js
• ejs, ejs
Express.js
Idea


• lovely routing
• request rendering
• response rendering
• kill callback soup (middleware)
The model



• not quite MVC
• more like VC
Lovely routing


• app.get(‘/a/path’, a_function)
• app.post(‘/a/path’, a_function)
• app.put( ...
• app.delete( ...
Request rendering (old)


• it’s just a socket
• manually parse query
• manually fetch body ...
Request rendering (new)


• app.post(‘/path:id’, req, res)
• req is easy to use object
• req.params is get parameters
• req.body is post parameters
Middleware (old)

app.get('/user/:id', function(req, res, next){
  loadUser(req.params.id, function(err,
user){
    if (err) return next(err);
    res.send('Viewing user ' + user.name);
  });
});
Middleware (new)
function loadUser(req, res, next) {
  var user = users[req.params.id];
  if (user) {
    req.user = user;
    next();
  } else {
    next(new Error('Failed to load user '
+ req.params.id));
  }
}
              app.get('/user/:id', loadUser, function(req, res){
                res.send('Viewing user ' + req.user.name);
              });
Response rendering


• res.send()
• res.send({some: ‘json’})
• res.render(‘index’, {some: ‘data’})
• res.download(‘/a/file.png’, ‘pic.png’)
underscore.js
A toolbelt


• convenience functions
• just use _.<something>
• reverts to native if possible
The important parts


• map, reduce, select, any, groupBy etc.
• first, last, rest ...
• bind, memoize, wrap ...
• keys, values, functions, extend ...
backbone.js
MVC!



• client-side MVC
• javascriptMVC, extJS, knockout.js ...
Idea


• kill callback soup
• easy event binding
• fuck the ‘this’
• magically bind data to representation
Result



• data stored in objects
• change data, view reacts
Where data?


• models: var Book =
  Backbone.Model.extend({urlRoot : '/book'});


• collections: var Notes =
  Backbone.Collection.extend({url: '/notes'});
Magical REST


• model.save()
• model.update()
• collection.fetch()
• etc.
Events (old)



• $(“#fancyselector”).click(function ..
• $(“#form”).submit(function ..
Events (new)



• events: { ‘click #fancyselector’: “func”
• ‘this’ magically bound perfectly
Views


• make a render function
• this.model.bind(“change”,
  this.render)

• model.set(“foo”, “bar”) --> renders!
ejs, ejs
ejs, ejs?


• two tools, same name
• node.js
• client-side
• “embeddable javascript”
Idea


• embed some JS in your HTML
• <% .. %>
• a bunch of convenience functions
Ejs-client


• it’s actually more powerful
• img_tag, textarea, etc. helpers
• many ways to get a template
Questions?
Btw, go to http://postme.me

More Related Content

PPTX
Object Oriented Programing in JavaScript
PPTX
Javascript first-class citizenery
KEY
【前端Mvc】之豆瓣说实践
PPTX
Getting Started with Javascript
PPTX
Simple blog wall creation on Java
PPTX
J query resh
PPTX
Backbonejs for beginners
ODP
BackboneJS and friends
Object Oriented Programing in JavaScript
Javascript first-class citizenery
【前端Mvc】之豆瓣说实践
Getting Started with Javascript
Simple blog wall creation on Java
J query resh
Backbonejs for beginners
BackboneJS and friends

What's hot (20)

PDF
SproutCore and the Future of Web Apps
PDF
Workshop 12: AngularJS Parte I
PDF
Laravel 8 export data as excel file with example
PPTX
Jqueryppt (1)
PDF
Converting a Rails application to Node.js
PDF
jQuery Effects
PPT
Managing JavaScript Dependencies With RequireJS
PDF
Backbone
PPTX
AngularJS - a radically different way of building Single Page Apps
PPTX
Mobile services on windows azure (part2)
PDF
jQuery - Chapter 1 - Introduction
PDF
Simpler Core Data with RubyMotion
PDF
Angularjs architecture
PPTX
Angular js 1.0-fundamentals
PPTX
AngularJS intro
PPTX
AngularJS Beginners Workshop
PPT
Dynamic Application Development by NodeJS ,AngularJS with OrientDB
PDF
JavaScript para Graficos y Visualizacion de Datos
PPTX
Single Page Apps with Drupal 8
PPTX
Introducing AngularJS
SproutCore and the Future of Web Apps
Workshop 12: AngularJS Parte I
Laravel 8 export data as excel file with example
Jqueryppt (1)
Converting a Rails application to Node.js
jQuery Effects
Managing JavaScript Dependencies With RequireJS
Backbone
AngularJS - a radically different way of building Single Page Apps
Mobile services on windows azure (part2)
jQuery - Chapter 1 - Introduction
Simpler Core Data with RubyMotion
Angularjs architecture
Angular js 1.0-fundamentals
AngularJS intro
AngularJS Beginners Workshop
Dynamic Application Development by NodeJS ,AngularJS with OrientDB
JavaScript para Graficos y Visualizacion de Datos
Single Page Apps with Drupal 8
Introducing AngularJS
Ad

Similar to Tools that get you laid (20)

PPTX
Backbone.js
PPTX
Planbox Backbone MVC
PPTX
Backbone
PPTX
Javascript Frameworks Comparison
ODP
Javascript frameworks: Backbone.js
PPTX
Express JS
PDF
Intro to BackboneJS + Intermediate Javascript
PPTX
Javascript Frameworks Comparison - Angular, Knockout, Ember and Backbone
PDF
Javascript Application Architecture with Backbone.JS
PDF
Developing Backbonejs Applications Early Release Addy Osmani
PPTX
Backbone the Good Parts
PDF
Learn backend java script
PPTX
Javascript for Wep Apps
PPT
Backbone.js
PPTX
Drupal Backbone.js in the Frontend
PDF
The State of Front-end At CrowdTwist
PPTX
Give your web apps some backbone
PDF
Backbone.js slides
PPTX
Single Page Application Development with backbone.js and Simple.Web
PDF
Viking academy backbone.js
Backbone.js
Planbox Backbone MVC
Backbone
Javascript Frameworks Comparison
Javascript frameworks: Backbone.js
Express JS
Intro to BackboneJS + Intermediate Javascript
Javascript Frameworks Comparison - Angular, Knockout, Ember and Backbone
Javascript Application Architecture with Backbone.JS
Developing Backbonejs Applications Early Release Addy Osmani
Backbone the Good Parts
Learn backend java script
Javascript for Wep Apps
Backbone.js
Drupal Backbone.js in the Frontend
The State of Front-end At CrowdTwist
Give your web apps some backbone
Backbone.js slides
Single Page Application Development with backbone.js and Simple.Web
Viking academy backbone.js
Ad

Recently uploaded (20)

PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PPTX
Big Data Technologies - Introduction.pptx
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Chapter 3 Spatial Domain Image Processing.pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Machine learning based COVID-19 study performance prediction
PPTX
MYSQL Presentation for SQL database connectivity
Unlocking AI with Model Context Protocol (MCP)
Review of recent advances in non-invasive hemoglobin estimation
Programs and apps: productivity, graphics, security and other tools
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
Encapsulation_ Review paper, used for researhc scholars
Advanced methodologies resolving dimensionality complications for autism neur...
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Understanding_Digital_Forensics_Presentation.pptx
Big Data Technologies - Introduction.pptx
Digital-Transformation-Roadmap-for-Companies.pptx
MIND Revenue Release Quarter 2 2025 Press Release
Diabetes mellitus diagnosis method based random forest with bat algorithm
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Chapter 3 Spatial Domain Image Processing.pdf
The AUB Centre for AI in Media Proposal.docx
Machine learning based COVID-19 study performance prediction
MYSQL Presentation for SQL database connectivity

Tools that get you laid

Editor's Notes