Free Sample
+ Collection

Backbone.js Patterns and Best Practices

Starting
Swarnendu De

Improve your Backbone.js skills with this step-by-step guide to patterns and best practice. It will help you reduce boilerplate in your code and provide plenty of open source plugin solutions to common problems along the way.
$23.99
$39.99
RRP $23.99
RRP $39.99
eBook
Print + eBook

Want this title & more?

$12.99 p/month

Subscribe to PacktLib

Enjoy full and instant access to over 2000 books and videos – you’ll find everything you need to stay ahead of the curve and make sure you can always get the job done.

Book Details

ISBN 139781783283576
Paperback174 pages

About This Book

  • Offers solutions to common Backbone.js related problems that most developers face
  • Shows you how to use custom widgets, plugins, and mixins to make your code reusable
  • Describes patterns and best practices for large scale JavaScript application architecture and unit testing applications with QUnit and SinonJS frameworks

Who This Book Is For

This book is for JavaScript developers who work with Backbone.js and want to learn the best design patterns to develop complex web applications. Basic knowledge of Backbone.js and JavaScript is essential.

Table of Contents

Chapter 1: Reducing Boilerplate with Plugin Development
Basic components of Backbone.js
Using Underscore.js
Re-using code with extensions
Understanding JavaScript mixins
Summary
Chapter 2: Working with Views
Basic usage of views
Partially updating a view
Understanding nested views
Working with templates
Understanding automatic model-view data binding
Using Marionette's ItemView, CollectionView, and CompositeView
Using Layout Manager
Summary
Chapter 3: Working with Models
Basic usage of models
Validating the data
Serializing models
Understanding the relational data model
Summary
Chapter 4: Working with Collections
Basic usage of collections
Sorting a collection
Filtering a collection
Understanding the collection of multiple model types
Summary
Chapter 5: Routing Best Practices and Subrouting
Working with routers
Best practices for working with routers
Subrouting – a key to organizing complex apps
Summary
Chapter 6: Working with Events, Sync, and Storage
Understanding custom events
Using an event dispatcher
Avoiding memory leaks with the listenTo() method
Overriding the Backbone.sync() method
Offline storage using the Backbone.LocalStorage adapter
Summary
Chapter 7: Organizing Backbone Applications – Structure, Optimize, and Deploy
Understanding the application directory structure
Working with Asynchronous Module Definition
Creating application architecture
Summary
Chapter 8: Unit Test, Stub, Spy, and Mock Your App
Understanding why unit testing is important
Testing with QUnit
Using test spies, stubs, and mocks with SinonJS
Summary

What You Will Learn

  • Develop custom plugins and mixins to reduce boilerplate in your code
  • Learn about Backbone view management with nested views, subviews, layout manager, and Marionette views
  • Understand template management by storing and pre-compiling templates
  • Explore model validation with validation plugins and learn model serialization and relational data management with nested models
  • Work with collections to implement multiple sorting and filtering behavior
  • Create solid application architecture with AMD and different popular design patterns

In Detail

Backbone.js is a super light framework that allows you to structure your JavaScript codes in an MV* fashion. This framework is an excellent tool when it comes to creating an organized and modular code base for web apps of any size or complexity. Although lightweight, Backbone.js results in lots of boilerplate. Learning the best practices and design patterns will help you avoid these problems and allow you to ensure that the best standards are followed.

Backbone.js Patterns and Best Practices is packed with examples that will help you work with Backbone.js components. It also gives solutions to common problems faced by developers. It gives a complete overview of plugin development, large scale application architecture, and unit testing as well.

Starting with a discussion of why reducing boilerplate in your JavaScript code is essential, Backbone.js Patterns and Best Practices explains how to enforce reusability in your code by creating plugins and mixins. You will learn about patterns and best practices for Backbone views, models, collections, routers, and events.

You will discover solutions to common problems that developers face through simple examples, and delve into the best open source plugins available to solve these problems when they arise. This book is an excellent collection of design and implementation patterns that will help you structure and develop complex Backbone.js applications easily.

Authors

Read More

Recommended for You