SlideShare a Scribd company logo
REAL WORLD SPA 
A Knockout Case Study 
Cory House @housecor 
.com
Learn From My Mistakes
Knowledge Survey 
Have you built a SPA? 
Know Ember, Angular, Backbone? 
Worked with Knockout, Durandal, Require, Fiddler, AJAX?
Here’s the Focus 
1. App walk-through 
2. 10 Lessons Learned 
3. Does this even make sense?
What monthly 
payment would you 
like?
App Demo
New App: Two Goals 
1. Cross Platform 
2. Speed
Lessons Learned
Decisions are Hard. 
And we were wrong. A lot.
Sea of Decisions
but…
Real World Single Page App - A Knockout Case Study
Light 
Unopinionated 
Library 
Rich 
Opinionated 
Framework
Light 
Unopinionated 
Library 
Rich 
Opinionated 
Framework
Pick a Language?!
Service Layer 
WebAPI
And Pick a Promise Library… 
Q RSVP 
Bluebird jQuery
And a Testing Framework…
Utility Libraries
Data
Network Transport 
AJAX 
Go 2-way: 
WebSocket 
AJAX Long-polling 
Adobe® Flash® Socket 
AJAX multipart streaming 
Forever Iframe 
JSONP Polling 
Or punt:
NoSQL?
Unobtrusive JS 
Dead?
1999 2007 2013 
Inline Unobtrusive Databinding
Unobtrusive JavaScript Movement: Dead? 
1999 Inline 
2007 Unobtrusive 
Knockout 
Angular 
2013 Databinding
Databinding Advantages 
Discoverability 
Clarity 
Less Code
Consider the Maintenance Programmer 
Physically separating concerns that are logically intertwined 
without an explicit interface obfuscates rather than aids 
understanding.
Bundle & Minify 
Maybe not?
Heavy Load 
93 JS 
19 HTML 
5 CSS 
11 Images 
---------------- 
132 HTTP requests?!
The Full SPA 
93 JS files 
53 viewmodels 
9 libraries 
39 Popup windows 
56 HTML files 
94 RESTful endpoints
Why Minify and Bundle? 
1. Reduce HTTP requests to reduce load on server 
2. Speed page load 
3. Obfuscate code
Why Not Minify and Bundle? 
1. Prod no longer matches dev 
2. Risk of introducing obscure bugs 
3. Debugging in prod is more complex 
4. Complexity (and thus risk) must be justified
How’s Performance? It Depends. 
Chrome IE8 
Empty cache 6 13 
Warm cache 3 3 
Load first deal 1 2 
Load second deal 1 2 
Recalculate payment 1 2 
To nearest second
We’re blind to errors! 
That’s malpractice.
Real World Single Page App - A Knockout Case Study
‘Twas Blind, but Now I See…
Fast in Chrome? 
Meaningless.
Old IE, The Laggard 
10x slower 5x slower
1000 rows… 
In memory? No problem. 
In a table? Uh oh.
DOM Weight 
Traditional 
Duplicate elements rendered 
Client-side 
Single template
Cross Browser Testing 
Many options: http://bit.ly/16cXevo 
XP-More
Unix or Windows Mindset? 
No right answer.
Our Tech Stack
WebAPI 
ORMLite 
MSTest 
KnockoutJS Durandal RequireJS 
KendoUI 
Knockout.Mapping 
& Knockout-Kendo 
Toastr 
jQuery Q.js QUnit 
Our Stack
Why Use Knockout 
with Durandal? 
14% of our customers :_(
1. Convention 
2. Composition 
<div data-bind=“compose: ‘viewmodels/vehicle’></div> 
<!-- ko compose: ‘viewmodels/vehicle’ --><!-- /ko --> 
3. Routing
A Torrid Love Affair…
Real World Single Page App - A Knockout Case Study
Real World Single Page App - A Knockout Case Study
Real World Single Page App - A Knockout Case Study
WebAPI 
ORMLite 
MSTest 
KnockoutJS Durandal RequireJS 
KendoUI 
Knockout.Mapping 
& Knockout-Kendo 
Toastr 
jQuery Q.js QUnit 
Our Stack
If We Used AngularJS instead… 
WebAPI 
ORMLite 
MSTest 
AngularJS 
KendoUI
TypeScript or Test 
Or refactor at your own risk
My Awesome JS 
Refactoring Tool
And a Testing Framework…
What I’m testing: 
Service endpoints 
Business logic 
That the data displays (implied)
Architect Your JS like C#. 
DAL, BLL, Presentation…
Create a Client-Side “DAL” 
JSON.stringify 
Centralized service layer 
Single wrapper around $.ajax 
View 
ViewModel 
Service 
AJAX service
Keep Your Viewmodels Thin 
Create Business objects! 
Instantiate them in your viewmodels 
A 1,000+ line viewmodel is as smelly as a 1,000 class.
Where Should I Put the Business Logic? 
Avoid 
here. 
Prefer Here
Config Object Pattern 
Dynamism belongs in JSON
JavaScript Configuration Object Pattern 
JavaScript belongs in static .js files 
Not strings in C#, Java, etc. 
1 language per file 
Inject dynamism via JSON from the server.
JavaScript Configuration Object Pattern
Config Object Pattern: A Justification 
Separation of concerns 
Caching 
Minimizes string parsing overhead 
Code coloring 
Syntax checking 
Reusable 
Reduced payload 
Less abstraction 
bitnative.com/2013/10/06/javascript-configuration-object-pattern/
Manage Dependencies 
Keep the global namespace clear.
RequireJS 
Utilizes AMD pattern 
Dynamically load JS 
Inject dependencies 
Watch for circular dependencies
Stay DRY 
Don’t repeat viewmodels on server & client
var firstName = ko.observable(user.firstName); 
var middleName = ko.observable(user.middleName); 
var lastName = ko.observable(user.lastName); 
… 
Instead: 
var user = ko.mapping.fromJS(user);
How Do I Stay DRY? 
Use KO mapping plugin 
Inject nullos via the Configuration Object Pattern 
Ko.utils.
Does This Even Make Sense?
Why not? 
Proprietary business logic 
Low interactivity 
Slower page load 
Page is rarely called 
Complex – Too many choices! 
Debugging pain 
 Runtime errors 
 Cryptic 
 One mistake and nothing loads
Why? 
Responsive 
Rich Interactivity 
Separation of concerns 
Efficient 
Simple - Less abstraction 
 Debugging 
 No compile wait 
Faster page load
Real World Single Page App - A Knockout Case Study
SPA Experience Complete 
Cory House 
bitnative.com 
@housecor 
spkr8.com/t/35431

More Related Content

What's hot (20)

PPTX
Test driven development v1.0
Ganesh Kondal
 
PDF
Introduction to nodejs
James Carr
 
PPTX
Reactjs Introduction - Virtual DOM
Tamir Azrab
 
PPTX
Introduction to Javascript By Satyen
Satyen Pandya
 
PDF
Managing JavaScript Complexity
Jarrod Overson
 
PDF
Huge web apps web expo 2013
Daniel Steigerwald
 
PPT
Javascript by geetanjali
Geetanjali Bhosale
 
DOCX
Javascript tutorial
Abhishek Kesharwani
 
PDF
Javascript
Momentum Design Lab
 
PPT
Node.js an introduction
Meraj Khattak
 
PDF
Metaprogramming JavaScript
danwrong
 
PPTX
Javascript why what and how
sureshpraja1234
 
PPTX
A slightly advanced introduction to node.js
Sudar Muthu
 
PPTX
Introduction to Knockoutjs
jhoguet
 
PDF
An introduction to knockout.js
Emanuele DelBono
 
PPTX
REACT.JS : Rethinking UI Development Using JavaScript
Deepu S Nath
 
PDF
2019 PHP Serbia - Boosting your performance with Blackfire
Marko Mitranić
 
PDF
Knockout js session
Ravinder Mahajan
 
PDF
Data presentation with dust js technologies backing linkedin
Ruhaim Izmeth
 
PDF
AngularJS - Javascript framework for superheroes
Vincenzo Ferrari
 
Test driven development v1.0
Ganesh Kondal
 
Introduction to nodejs
James Carr
 
Reactjs Introduction - Virtual DOM
Tamir Azrab
 
Introduction to Javascript By Satyen
Satyen Pandya
 
Managing JavaScript Complexity
Jarrod Overson
 
Huge web apps web expo 2013
Daniel Steigerwald
 
Javascript by geetanjali
Geetanjali Bhosale
 
Javascript tutorial
Abhishek Kesharwani
 
Node.js an introduction
Meraj Khattak
 
Metaprogramming JavaScript
danwrong
 
Javascript why what and how
sureshpraja1234
 
A slightly advanced introduction to node.js
Sudar Muthu
 
Introduction to Knockoutjs
jhoguet
 
An introduction to knockout.js
Emanuele DelBono
 
REACT.JS : Rethinking UI Development Using JavaScript
Deepu S Nath
 
2019 PHP Serbia - Boosting your performance with Blackfire
Marko Mitranić
 
Knockout js session
Ravinder Mahajan
 
Data presentation with dust js technologies backing linkedin
Ruhaim Izmeth
 
AngularJS - Javascript framework for superheroes
Vincenzo Ferrari
 

Similar to Real World Single Page App - A Knockout Case Study (20)

PPTX
Node.js meetup 17.05.2017 ember.js - escape the javascript fatigue
Tobias Braner
 
PDF
Beginning MEAN Stack
Rob Davarnia
 
PDF
Developing realtime apps with Drupal and NodeJS
drupalcampest
 
PPTX
ASP.NET MVC Performance
rudib
 
PPT
Node js
Chirag Parmar
 
KEY
Agile JavaScript Testing
Scott Becker
 
PDF
Daniel Steigerwald - Este.js - konec velkého Schizma
Develcz
 
PPTX
Production debugging web applications
Ido Flatow
 
PPT
Developing Java Web Applications
hchen1
 
PPT
Ajax Performance
kaven yan
 
PDF
Web Development with Smalltalk
Mariano Martínez Peck
 
PDF
Google App Engine for Java v0.0.2
Matthew McCullough
 
PPTX
All of Javascript
Togakangaroo
 
PDF
2019 StartIT - Boosting your performance with Blackfire
Marko Mitranić
 
PDF
Isomorphic JavaScript with Nashorn
Maxime Najim
 
PPTX
Nodejs overview
Nicola Del Gobbo
 
PDF
Practical Thin Server Architecture With Dojo Sapo Codebits 2008
codebits
 
PPTX
Исполнение JS на сервере при масштабировании - что может пойти не так, Brian ...
Ontico
 
PDF
Why Nodejs Guilin Shanghai
Jackson Tian
 
PDF
Why Node.js
guileen
 
Node.js meetup 17.05.2017 ember.js - escape the javascript fatigue
Tobias Braner
 
Beginning MEAN Stack
Rob Davarnia
 
Developing realtime apps with Drupal and NodeJS
drupalcampest
 
ASP.NET MVC Performance
rudib
 
Node js
Chirag Parmar
 
Agile JavaScript Testing
Scott Becker
 
Daniel Steigerwald - Este.js - konec velkého Schizma
Develcz
 
Production debugging web applications
Ido Flatow
 
Developing Java Web Applications
hchen1
 
Ajax Performance
kaven yan
 
Web Development with Smalltalk
Mariano Martínez Peck
 
Google App Engine for Java v0.0.2
Matthew McCullough
 
All of Javascript
Togakangaroo
 
2019 StartIT - Boosting your performance with Blackfire
Marko Mitranić
 
Isomorphic JavaScript with Nashorn
Maxime Najim
 
Nodejs overview
Nicola Del Gobbo
 
Practical Thin Server Architecture With Dojo Sapo Codebits 2008
codebits
 
Исполнение JS на сервере при масштабировании - что может пойти не так, Brian ...
Ontico
 
Why Nodejs Guilin Shanghai
Jackson Tian
 
Why Node.js
guileen
 
Ad

Recently uploaded (20)

PPT
Why Reliable Server Maintenance Service in New York is Crucial for Your Business
Sam Vohra
 
PDF
MiniTool Power Data Recovery Crack New Pre Activated Version Latest 2025
imang66g
 
PDF
Balancing Resource Capacity and Workloads with OnePlan – Avoid Overloading Te...
OnePlan Solutions
 
PPTX
classification of computer and basic part of digital computer
ravisinghrajpurohit3
 
PPTX
Role Of Python In Programing Language.pptx
jaykoshti048
 
PDF
Protecting the Digital World Cyber Securit
dnthakkar16
 
PPTX
Presentation about variables and constant.pptx
kr2589474
 
PPTX
Contractor Management Platform and Software Solution for Compliance
SHEQ Network Limited
 
PDF
Using licensed Data Loss Prevention (DLP) as a strategic proactive data secur...
Q-Advise
 
PDF
Troubleshooting Virtual Threads in Java!
Tier1 app
 
PDF
AI Image Enhancer: Revolutionizing Visual Quality”
docmasoom
 
PPTX
Presentation about Database and Database Administrator
abhishekchauhan86963
 
PDF
Step-by-Step Guide to Install SAP HANA Studio | Complete Installation Tutoria...
SAP Vista, an A L T Z E N Company
 
PDF
On Software Engineers' Productivity - Beyond Misleading Metrics
Romén Rodríguez-Gil
 
PPTX
TRAVEL APIs | WHITE LABEL TRAVEL API | TOP TRAVEL APIs
philipnathen82
 
PPTX
GALILEO CRS SYSTEM | GALILEO TRAVEL SOFTWARE
philipnathen82
 
PDF
Infrastructure planning and resilience - Keith Hastings.pptx.pdf
Safe Software
 
PPTX
Employee salary prediction using Machine learning Project template.ppt
bhanuk27082004
 
PDF
New Download MiniTool Partition Wizard Crack Latest Version 2025
imang66g
 
PDF
How to Download and Install ADT (ABAP Development Tools) for Eclipse IDE | SA...
SAP Vista, an A L T Z E N Company
 
Why Reliable Server Maintenance Service in New York is Crucial for Your Business
Sam Vohra
 
MiniTool Power Data Recovery Crack New Pre Activated Version Latest 2025
imang66g
 
Balancing Resource Capacity and Workloads with OnePlan – Avoid Overloading Te...
OnePlan Solutions
 
classification of computer and basic part of digital computer
ravisinghrajpurohit3
 
Role Of Python In Programing Language.pptx
jaykoshti048
 
Protecting the Digital World Cyber Securit
dnthakkar16
 
Presentation about variables and constant.pptx
kr2589474
 
Contractor Management Platform and Software Solution for Compliance
SHEQ Network Limited
 
Using licensed Data Loss Prevention (DLP) as a strategic proactive data secur...
Q-Advise
 
Troubleshooting Virtual Threads in Java!
Tier1 app
 
AI Image Enhancer: Revolutionizing Visual Quality”
docmasoom
 
Presentation about Database and Database Administrator
abhishekchauhan86963
 
Step-by-Step Guide to Install SAP HANA Studio | Complete Installation Tutoria...
SAP Vista, an A L T Z E N Company
 
On Software Engineers' Productivity - Beyond Misleading Metrics
Romén Rodríguez-Gil
 
TRAVEL APIs | WHITE LABEL TRAVEL API | TOP TRAVEL APIs
philipnathen82
 
GALILEO CRS SYSTEM | GALILEO TRAVEL SOFTWARE
philipnathen82
 
Infrastructure planning and resilience - Keith Hastings.pptx.pdf
Safe Software
 
Employee salary prediction using Machine learning Project template.ppt
bhanuk27082004
 
New Download MiniTool Partition Wizard Crack Latest Version 2025
imang66g
 
How to Download and Install ADT (ABAP Development Tools) for Eclipse IDE | SA...
SAP Vista, an A L T Z E N Company
 
Ad

Real World Single Page App - A Knockout Case Study