SlideShare a Scribd company logo
Testable, client-side MVC apps in Javascript Demo using Spine, Jasmine, & node.JS
Motivation Browser environment is becoming increasingly powerful 'Serverside for everything' exists because there was no other choice Flash platform no longer required/ideal for rich interaction  Server infrastructure is expensive Push as much work onto the client as possible Less importance on what server-side tech you select Unnecessary to talk to server for every action More responsive interaction Smoother UX -> better customers* Web applications not web sites Web browser is (mostly) cross-platform * http://www.codinghorror.com/blog/2006/11/speed-still-matters.html
Thin-Server Architecture Server Responsibilities Persistence Storage & retrieval of unformatted data Sessions Validation Sanity Security Resource serving Modules Images DRY HTML CSS Handling/reporting state SEO/Accessibility Client Responsibilities Behaviour Navigation User Prompt Layout Visual Hierarchy Theme Data Presentation Data (e.g. JSON)  ->  HTML via templates Pseudo Persistence Caching Processing (eg filtering) Validation The eye candy is the application is the eye candy
Accessibility? Premature optimisation. Make something cool first. Simple to achieve later, IF you need it
Graceful Degredation? Premature optimisation.  Make something cool first. 
Give your code a fighting chance Polyfills   "A polyfill, or polyfiller, is a piece of code (or plugin) that provides the technology that you, the developer, expect the browser to provide natively. Flattening the API landscape if you will." https://github.com/Modernizr/Modernizr/wiki/HTML5-Cross-browser-Polyfills HTML5 + Shim/Shiv http://html5boilerplate.com/ http://www.modernizr.com/ CSS Reset http://www.cssreset.com/ http://html5boilerplate.com/ http://necolas.github.com/normalize.css/  
Add some structure MVC Backbone  http://documentcloud.github.com/backbone/ Spine  http://maccman.github.com/spine/ Tests jasmine  http://pivotal.github.com/jasmine/ jasmine-node  https://github.com/mhevery/jasmine-node expresso  http://visionmedia.github.com/expresso/ vows  http://vowsjs.org/
Visuals should be easy and fun A language that compiles to CSS stylus  http://learnboost.github.com/stylus/   https://github.com/lucasmazza/stylus_rails sass  http://sass-lang.com/ A language that compiles   to HTML jade  http://jade-lang.com/ haml  http://haml-lang.com/ Language that cross-browserizes your css & adds cool stuff nib  https://github.com/visionmedia/nib Compass  http://compass-style.org/ Templating system for lists   http://jsperf.com/dom-vs-innerhtml-based-templating/160
Optimise your resources Image Reduction http://pornel.net/imagealpha http://imageoptim.pornel.net/ Smush.it via YSlow http://developer.yahoo.com/yslow/smushit/ JS Reduction Google Closure Compiler  http://code.google.com/closure/compiler/ UglifyJS  https://github.com/mishoo/UglifyJS http://badassjs.com/post/971960912/uglifyjs-a-fast-new-javascript-compressor-for-node-js      CSS Reduction YUICompressor  http://tools.w3clubs.com/cssmin/
Familiar? Out of date tests, or none at all Out of date documentation, or none at all "Refactoring? Just write it well the first time" Knee-jerk Methodology Minimal technology options, from 5+ years ago
Self Improvement http://stackoverflow.com/questions/1711/what-is-the-single-most-influential-book-every-programmer-should-read
CommonJS Community Driven The W3C of Javascript Define specs for console modules assert packages Module spec 
Loading Modules Load modules with the CommonJS require() function RequireJS = async require() Compare with HeadJS Transparent, client-side require: Stitch/Browserify, – dependency on nodeJS though In-browser support not ideal, but manageable - workarounds available //commonjs synchronous require var  module  =  require( 'moduleName' ) //requirejs asynchronous require var  module; require( 'moduleName' ,  function (loadedModule) {      module  =  loadedModule; }) // headjs has no concept of commonjs modules head.js( &quot;moduleName.js&quot; ,  &quot;myOtherModule.js&quot; ,  function () {      // module loaded }); <head> <script  src= &quot;/mymodule.js&quot; ></script> <script  src= &quot;/myOtherModule.js&quot; ></script> <script  src= &quot;/YAM.js&quot; ></script> <script  src= &quot;/ilovemodules.js&quot; ></script> <script>        // ewww. Polluting the global namespace?!        myModule.use() </script> </head>
CommonJS Modules Avoid naming collisions Wraps module in a closure, keeping the module's internals private Encourages Good Practice Exposes properties through the special module.exports object // define my module var  Me  =  {       name :   &quot;Tim&quot;      ,doDishes :   function () {          return   false      } } //export module module.exports  =  Me;
Resources nodeJS Patterns http://www.derekhammer.com/2010/07/05/node-js-patterns.html Mastering Node http://visionmedia.github.com/masteringnode/book.html Javascript Templating http://jsperf.com/dom-vs-innerhtml-based-templating/160
Resources Polyfills https://github.com/Modernizr/Modernizr/wiki/HTML5-Cross-browser-Polyfills http://blog.reybango.com/2010/10/11/how-polyfills-fill-in-the-gaps-to-make-html5-and-css3-usable-today/

More Related Content

PDF
Single Page Application Best practices
PPTX
Single Page WebApp Architecture
ODP
A Good PHP Framework For Beginners Like Me!
PPTX
Webworks
PPTX
Building single page applications
PDF
Building a Single-Page App: Backbone, Node.js, and Beyond
PDF
JSConf US 2014: Building Isomorphic Apps
PPTX
Single Page Application Best practices
Single Page WebApp Architecture
A Good PHP Framework For Beginners Like Me!
Webworks
Building single page applications
Building a Single-Page App: Backbone, Node.js, and Beyond
JSConf US 2014: Building Isomorphic Apps

What's hot (19)

PDF
Node PDX: Intro to Sails.js
PPT
Taking Advantage of Client Side / JavsScript Templates in Rich Internet Appli...
PPTX
HTML5 for Rich User Experience
PDF
Web components api + Vuejs
PDF
Web Fundamentals Crash Course
ODP
Making Chrome Extension with AngularJS
PDF
[D2 오픈세미나]2.모바일웹디버깅
PPT
Web design services
PPT
Jsp Comparison
PDF
Blazor web apps
PPT
Jsp(java server pages)
ODP
WordPress as a Platform - talk to Bristol Open Source Meetup, 2014-12-08
PDF
You wanna crypto in AEM
PPTX
Making Single Page Applications (SPA) faster
PPT
PPT
Os mobile
PDF
Transforming Front-End Disaster Code™ Into A Maintainable Masterpiece
PPTX
Power Training DevDays 2009
PDF
Build single page applications using AngularJS on AEM
Node PDX: Intro to Sails.js
Taking Advantage of Client Side / JavsScript Templates in Rich Internet Appli...
HTML5 for Rich User Experience
Web components api + Vuejs
Web Fundamentals Crash Course
Making Chrome Extension with AngularJS
[D2 오픈세미나]2.모바일웹디버깅
Web design services
Jsp Comparison
Blazor web apps
Jsp(java server pages)
WordPress as a Platform - talk to Bristol Open Source Meetup, 2014-12-08
You wanna crypto in AEM
Making Single Page Applications (SPA) faster
Os mobile
Transforming Front-End Disaster Code™ Into A Maintainable Masterpiece
Power Training DevDays 2009
Build single page applications using AngularJS on AEM
Ad

Similar to Testable client side_mvc_apps_in_javascript (20)

PPTX
Building SPA’s (Single Page App) with Backbone.js
PPT
Intro to SPA using JavaScript & ASP.NET
PDF
Javascript Client & Server Architectures
PDF
Server Side Javascript
PPTX
Flu3nt highlights
PPT
HTML5 Overview
PDF
JS Single-Page Web App Essentials
ODP
Ample SDK: A tour de force
KEY
Single Page Applications - Desert Code Camp 2012
DOCX
Single Page Application
PDF
Architecting non-trivial browser applications (Jazoon 2012)
ODP
Javascript Update May 2013
PPTX
Mobile gotcha
PPTX
Going Offline with JS
PPTX
Front End Development | Introduction
PPTX
Javascript for Wep Apps
PPTX
Large-Scale Web Development with JavaScript
PPTX
Jade & Javascript templating
KEY
20120802 timisoara
PPTX
HTML5 - Future of Web
Building SPA’s (Single Page App) with Backbone.js
Intro to SPA using JavaScript & ASP.NET
Javascript Client & Server Architectures
Server Side Javascript
Flu3nt highlights
HTML5 Overview
JS Single-Page Web App Essentials
Ample SDK: A tour de force
Single Page Applications - Desert Code Camp 2012
Single Page Application
Architecting non-trivial browser applications (Jazoon 2012)
Javascript Update May 2013
Mobile gotcha
Going Offline with JS
Front End Development | Introduction
Javascript for Wep Apps
Large-Scale Web Development with JavaScript
Jade & Javascript templating
20120802 timisoara
HTML5 - Future of Web
Ad

More from Timothy Oxley (6)

PDF
Modular vs Monolith
PDF
Components vs Frameworks
PDF
Bundling Client Side Assets
PDF
component: ruby gems for the browser
PDF
Benefits of Clientside templating for Red Dot Ruby
PDF
Intro to testing Javascript with jasmine
Modular vs Monolith
Components vs Frameworks
Bundling Client Side Assets
component: ruby gems for the browser
Benefits of Clientside templating for Red Dot Ruby
Intro to testing Javascript with jasmine

Recently uploaded (20)

PDF
Electronic commerce courselecture one. Pdf
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
A Presentation on Artificial Intelligence
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
KodekX | Application Modernization Development
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Encapsulation theory and applications.pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Modernizing your data center with Dell and AMD
Electronic commerce courselecture one. Pdf
NewMind AI Weekly Chronicles - August'25 Week I
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
20250228 LYD VKU AI Blended-Learning.pptx
Network Security Unit 5.pdf for BCA BBA.
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Advanced methodologies resolving dimensionality complications for autism neur...
MYSQL Presentation for SQL database connectivity
A Presentation on Artificial Intelligence
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
The Rise and Fall of 3GPP – Time for a Sabbatical?
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Unlocking AI with Model Context Protocol (MCP)
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
NewMind AI Monthly Chronicles - July 2025
KodekX | Application Modernization Development
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Encapsulation theory and applications.pdf
Encapsulation_ Review paper, used for researhc scholars
Modernizing your data center with Dell and AMD

Testable client side_mvc_apps_in_javascript

  • 1. Testable, client-side MVC apps in Javascript Demo using Spine, Jasmine, & node.JS
  • 2. Motivation Browser environment is becoming increasingly powerful 'Serverside for everything' exists because there was no other choice Flash platform no longer required/ideal for rich interaction  Server infrastructure is expensive Push as much work onto the client as possible Less importance on what server-side tech you select Unnecessary to talk to server for every action More responsive interaction Smoother UX -> better customers* Web applications not web sites Web browser is (mostly) cross-platform * http://www.codinghorror.com/blog/2006/11/speed-still-matters.html
  • 3. Thin-Server Architecture Server Responsibilities Persistence Storage & retrieval of unformatted data Sessions Validation Sanity Security Resource serving Modules Images DRY HTML CSS Handling/reporting state SEO/Accessibility Client Responsibilities Behaviour Navigation User Prompt Layout Visual Hierarchy Theme Data Presentation Data (e.g. JSON)  ->  HTML via templates Pseudo Persistence Caching Processing (eg filtering) Validation The eye candy is the application is the eye candy
  • 4. Accessibility? Premature optimisation. Make something cool first. Simple to achieve later, IF you need it
  • 5. Graceful Degredation? Premature optimisation.  Make something cool first. 
  • 6. Give your code a fighting chance Polyfills   &quot;A polyfill, or polyfiller, is a piece of code (or plugin) that provides the technology that you, the developer, expect the browser to provide natively. Flattening the API landscape if you will.&quot; https://github.com/Modernizr/Modernizr/wiki/HTML5-Cross-browser-Polyfills HTML5 + Shim/Shiv http://html5boilerplate.com/ http://www.modernizr.com/ CSS Reset http://www.cssreset.com/ http://html5boilerplate.com/ http://necolas.github.com/normalize.css/  
  • 7. Add some structure MVC Backbone  http://documentcloud.github.com/backbone/ Spine  http://maccman.github.com/spine/ Tests jasmine  http://pivotal.github.com/jasmine/ jasmine-node  https://github.com/mhevery/jasmine-node expresso  http://visionmedia.github.com/expresso/ vows  http://vowsjs.org/
  • 8. Visuals should be easy and fun A language that compiles to CSS stylus  http://learnboost.github.com/stylus/   https://github.com/lucasmazza/stylus_rails sass  http://sass-lang.com/ A language that compiles   to HTML jade  http://jade-lang.com/ haml  http://haml-lang.com/ Language that cross-browserizes your css & adds cool stuff nib  https://github.com/visionmedia/nib Compass  http://compass-style.org/ Templating system for lists   http://jsperf.com/dom-vs-innerhtml-based-templating/160
  • 9. Optimise your resources Image Reduction http://pornel.net/imagealpha http://imageoptim.pornel.net/ Smush.it via YSlow http://developer.yahoo.com/yslow/smushit/ JS Reduction Google Closure Compiler http://code.google.com/closure/compiler/ UglifyJS  https://github.com/mishoo/UglifyJS http://badassjs.com/post/971960912/uglifyjs-a-fast-new-javascript-compressor-for-node-js     CSS Reduction YUICompressor  http://tools.w3clubs.com/cssmin/
  • 10. Familiar? Out of date tests, or none at all Out of date documentation, or none at all &quot;Refactoring? Just write it well the first time&quot; Knee-jerk Methodology Minimal technology options, from 5+ years ago
  • 12. CommonJS Community Driven The W3C of Javascript Define specs for console modules assert packages Module spec 
  • 13. Loading Modules Load modules with the CommonJS require() function RequireJS = async require() Compare with HeadJS Transparent, client-side require: Stitch/Browserify, – dependency on nodeJS though In-browser support not ideal, but manageable - workarounds available //commonjs synchronous require var module = require( 'moduleName' ) //requirejs asynchronous require var module; require( 'moduleName' , function (loadedModule) {      module = loadedModule; }) // headjs has no concept of commonjs modules head.js( &quot;moduleName.js&quot; , &quot;myOtherModule.js&quot; , function () {      // module loaded }); <head> <script src= &quot;/mymodule.js&quot; ></script> <script src= &quot;/myOtherModule.js&quot; ></script> <script src= &quot;/YAM.js&quot; ></script> <script src= &quot;/ilovemodules.js&quot; ></script> <script>        // ewww. Polluting the global namespace?!        myModule.use() </script> </head>
  • 14. CommonJS Modules Avoid naming collisions Wraps module in a closure, keeping the module's internals private Encourages Good Practice Exposes properties through the special module.exports object // define my module var Me = {       name : &quot;Tim&quot;      ,doDishes : function () {          return false      } } //export module module.exports = Me;
  • 15. Resources nodeJS Patterns http://www.derekhammer.com/2010/07/05/node-js-patterns.html Mastering Node http://visionmedia.github.com/masteringnode/book.html Javascript Templating http://jsperf.com/dom-vs-innerhtml-based-templating/160
  • 16. Resources Polyfills https://github.com/Modernizr/Modernizr/wiki/HTML5-Cross-browser-Polyfills http://blog.reybango.com/2010/10/11/how-polyfills-fill-in-the-gaps-to-make-html5-and-css3-usable-today/

Editor's Notes

  • #3: Serverside technology and jobs Serverside technology and vendor lock-in Serverside technology and legacy Possible issues with browser environments becoming outdated quickly Probably a good thing though
  • #4: Your database operations should be abstracted anyway Persistence &amp;  Caching     if the client has already downloaded that data why do they need to download it again Client-side prediction - quake Client should do anything it can do easily.
  • #5: in a quick bit of research, looks like less than 5%, more IE5.5 users
  • #6: Doesn&apos;t need to be complicated don&apos;t let it scare you away from making an awesome app  There&apos;s always a way to fall back nicely Regressive Enhancement
  • #7: One of the best things about javascript is how fast it moves. Since beginning this 2 months ago, the hardest part has been selecting the right tools.  Modernizer is a HTML5 shim and a feature detector HTML5 Boilerplate is a shim and a CSS reset also includes a bunch of css stubs. it&apos;s a little bloated and to get started you may want to go for something a little more lightweight
  • #9: Variables Mixins Cross-browser Templates
  • #10: CSS not included
  • #11: No Tests,  Bugs around every corner No guarantee that the app actually works Rigorous manual testing means testing doens&apos;t happen Unprofessional Documentation The original developer(s) only person who can fix bugs without inducing homicidal rage Documentation gets out of sync if it&apos;s too heavy only when totally necessary &amp;quot;Refactoring? Just write it well the first time&amp;quot; Code gets worse with time Urge to rewrite each piece of software every 6 months Knee-jerk Methodology Always in crisis mode Impossible to keep deadlines Overworked staff Minimal technology options Sticking with what you know Don&apos;t fix it if it ain&apos;t broke  When all you have is a hammer everything looks like a nail
  • #12: There are others but these ones are most general. Allows you to identify &apos;code smells&apos; in any language Surprising how many people don&apos;t read this kind of material These books make it easier to communicate ideas and me not sound like a madman with strange ideas designed to ruin projects