Skip to Content
Learning JavaScript Design Patterns
book

Learning JavaScript Design Patterns

by Addy Osmani
July 2012
Intermediate to advanced
254 pages
6h 16m
English
O'Reilly Media, Inc.
Content preview from Learning JavaScript Design Patterns

Backbone.js Versus KnockoutJS

Understanding the subtle differences between MVC, MVP, and MVVM is important, but developers ultimately will ask whether they should consider using KnockoutJS over Backbone based in what we’ve learned. The following notes may be of help here:

  • Both libraries are designed with different goals in mind, and it’s often not as simple as just choosing MVC or MVVM.

  • If data binding and two-way communication are your main concerns, KnockoutJS is definitely the way to go. Practically any attribute or value stored in DOM nodes can be mapped to JavaScript objects with this approach.

  • Backbone excels with its ease of integration with RESTful services, while KnockoutJS Models are simply JavaScript objects and code needed for updating the Model must be written by the developer.

  • KnockoutJS has a focus on automating UI bindings, which requires significantly more verbose custom code if attempting to do this with Backbone. This isn’t a problem with Backbone itself per se, as it purposefully attempts to stay out of the UI. Knockback does, however, attempt to assist with this problem.

  • With KnockoutJS, we can bind our own functions to ViewModel observables, which are executed any time the observable changes. This allows us the same level of flexibility as can be found in Backbone.

  • Backbone has a solid routing solution built in, while KnockoutJS offers no routing options out of the box. One can, however, easily fill in this behavior if needed using Ben Alman’s BBQ plug-in or a standalone ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Mastering JavaScript Design Patterns - Second Edition

Mastering JavaScript Design Patterns - Second Edition

Simon Timms
JavaScript Patterns

JavaScript Patterns

Stoyan Stefanov

Publisher Resources

ISBN: 9781449334840Errata Page