I've been a zone leader with DZone since 2008, and I'm crazy about community. Every day I get to work with the best that JavaScript, HTML5, Android and iOS has to offer, creating apps that truly make at difference, as principal front-end architect at Avego. James is a DZone Zone Leader and has posted 639 posts at DZone. You can read more from them at their website. View Full User Profile

Beginning Backbone: My First Book

12.23.2013
| 3732 views |
  • submit to reddit

It’s been a long time ambition of mine to write a technical book. In the second half of 2013, I finally got the opportunity to do that, publishing Beginning Backbone.js with Apress. The book is available to purchase now, in all the usual formats.

Read (or scroll, but I’d prefer you read!) to the end of this post to get an excellent 30% off the ebook price until January 23)

Who’s The Book For? Everyone

When planning this book, I had a number of different readers in mind. As such, I feel that I’ve written this book to appeal across the board. JavaScript novices will find the book useful, as it starts at the simplest level. At the same time, experts should find this to be an excellent way to learn Backbone inside out.

I also wanted this book to appeal to CTOs, who are hearing that Backbone is (or isn’t) the next best thing for their web app: this book will help them form their own opinion. Finally, the book will assist teams who are getting to grips with large scale JavaScript application development.  With chapters covering test driven development, best practices and continuous integration, the book shows the level of maturity that JavaScript has reached.

What’s Backbone? 

At this point, I’m sure most people have heard about Backbone, a library that helps organise your JavaScript code in a structured Model View * format. The thing that I like most about Backbone is that it is un-opinionated, unlike Angular and Meteor. While this results in the developer needing to write more boilerplate code, it gives a very comfortable level of control. More about this later, as it is one of the most contentious issues in JavaScript framework selection these days.

What’s in the Book?

There are a number of different sections in the book that deal with different issues.

The Introductory Section

The first two chapters are designed to ease the reader into the web application development world. This first group of chapters introduce Backbone and similar libraries, along with going back-to-basics on object oriented JavaScript. If you’re rusty,it’s worth reading through this chapter to strengthen your understanding of what the language provides before diving into the library itself.

The Nuts & Bolts Section

The next batch of three chapters bring in the main concepts that exist in Backbone: Models, Collections, Views, Routers and Events. When going through the code examples in these chapters, a node.js server is used to provide a  REST API. While the depth in which node.js is explored is limited, I feel this a bonus for front-end developers. Each of these chapters iterates from the simplest possible version and then shows how additional configuration add more power.

I am particularly proud of the chapter that discusses Backbone Views. In true un-opinionated fashion, I explain how to use three of the leading template libraries for your views: UnderscoreHandlebars andMustache. Using a template library means that you get to avoid polluting your JavaScript with HTML strings. All three libraries listed have their own brilliances, but I find it difficult to beat Handlebars.

With this knowledge, Chapter 6 goes from start to finish with a complete application example. For this I went with Twitter, as it provides an easily understandable API. This gives the opportunity to use a Models, Collections, Routers and many different views on a single page. You end up with something that looks like the picture below.

app

The Extending Backbone Section

From the point, the book changes tone slightly. First I take a look at the huge number of extensions that have been written by the Backbone developer community. Here’s where the naysayers should look, if they feel that Backbones lack of data-view binding is hampering their progress. There are extensions available to help you out of almost any problem that you feel Backbone has. The beauty of this is that you can easily integrate most of these plugins in your Backbone applications. And it’s just as simple to take them out.

Similar to this chapter, Chapter 10 looks at Backbone Marionette and Thorax. These are amazing additions to Backbone, and deserved their own chapter. To put both through their paces, the Twitter sample application is refactored to utilise the features they provide.

The Discipline Section

With all this code, you’re going to need some discipline. That’s where the test driven development chapter will help. The most popular JavaScript testing frameworks out there are Jasmine and QUnit, so these are both described in detail, illustrating how to test out that sample Twitter application.

The next chapter shows how to use Grunt to add continuous integration to your JavaScript development. Grunt is an amazingly powerful tool that no JavaScript developer should be without. As a developer who has come from the Java world, it’s great to see something that easily surpasses the power of Maven or Ant.

The Doing-It-Better Section

For anyone who is already using Backbone, the chapter on best practices will help them to improve on what they already know. These tips were gathered from a wide variety of sources, as well as from my own experiences. Then the book closes out with tips on making your code even more manageable by usingRequire.js to created a modular codebase.

That final chapter also shows how to use the amazing Yeoman when you need to start from scratch in your development. The Backbone generator that’s included is brilliant. And once you discover the starting point that Yeoman provides, you’ll never look back.

So, In Summary

As you can see, while to book focuses on Backbone as the core topic, it extends much further. It’s a book that covers everything that you need to know about using JavaScript, along with Backbone, in a professional software development environment. I really hope you do enjoy reading it, and using anything that you learn, as much as I enjoyed writing it.

If you like the sound of this, why not buy the book. Or how about this:  I can give you 30% off the price of the ebook if you purchase the book from the Apress site using the code BCKJ14.  

Reference: http://www.jamessugrue.ie/softwaredev/beginning-backbone-my-first-book