Backbone.js Patterns and Best Practices

Backbone.js Patterns and Best Practices

Language: English

Pages: 174

ISBN: 1783283572

Format: PDF / Kindle (mobi) / ePub


A onestop guide to best practices and design patterns when building applications using Backtbone.js

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.

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.

Programming Windows 8 Apps with HTML, CSS, and JavaScript

The True Gold Standard: A Monetary Reform Plan without Official Reserve Currencies (2nd Edition)

Privatizing China: Socialism from Afar

Building Web Reputation Systems

Getting Started with Phalcon

iOS Programming: The Big Nerd Ranch Guide (3rd Edition) (Big Nerd Ranch Guides)

 

 

 

 

 

 

 

 

 

 

 

 

point of the application. You will see its usage in the following section when we will discuss working with AMD. The app.js file holds the application class that acts as the topmost parent class of the application. All the utility files such as utility.js or helper.js, which mostly contain the helper methods, sit in the util folder. The test folder is the main directory in which all the test scripts are stored. The config and mixin folders are there to store the config and reusable mixin files

to develop large-scale web application architecture. This book is not a general introduction to Backbone.js or JavaScript design patterns. There are lots of books, tutorials, and screencasts available that cover a general introduction in great detail. While this book will discuss the basics of the Backbone.js components in each chapter, the main priority will be to provide you with the concepts of developing a robust, high quality, and flexible code base. Conventions In this book, you will find

of a function. So, with AMD, you can define all of your files in the same way. The script dependencies are loaded as we saw previously, and the text dependencies can be loaded using the text plugin (https://github.com/requirejs/text) of RequireJS. We already discussed this thoroughly in Appendix C, Organizing Templates with AMD and Require.js, when we loaded the external template files using this plugin. In the following section, we are going to see how we can initiate a complete application

common utility methods. • DOM handling: The more you interact with the DOM in your views, the more difficult will it be to maintain in the later stage. Always try to reduce direct DOM manipulation as much as you can. • Error handler: Keep a generic error/exception handler ready; it should work as a single point for the errors/warnings and display messages to the users. • Memory management: In single-page large applications, memory leak is a real point of concern. So, you must be very much

Applications by Addy Osmani (http://addyosmani.github.io/backbone-fundamentals/) • Blog posts by Derick Bailey (http://lostechies.com/derickbailey/) • Patterns For Large-Scale JavaScript Application Architecture by Addy Osmani: °° http://addyosmani.com/largescalejavascript/ °° https://speakerdeck.com/addyosmani/large-scalejavascript-application-architecture • Scalable JavaScript Application Architecture by Nicholas Zakas (http://www.youtube.com/watch?v=vXjVFPosQHw) • If you are a beginner,

Download sample

Download