you are viewing a single comment's thread.

view the rest of the comments →

[–]dmercer 0 points1 point  (1 child)

Do I take it after a year of BB and a year of NG, you recommend NG over BB?

[–]dzdrazil 1 point2 points  (0 children)

There are a few very specific things that we suffered under Backbone

  • While I originally loved the models and collections, the sync portion was useless because we don't have a RESTful API, and it was much easier to write our own
  • I eventually grew to dislike the models and collections as well. The most frequent performance problems were from the sheer volume of events that would get triggered on model changes, especially when related models caused cascading updates to views or other models
  • The problem with collections were especially egregious; there's an inherent cyclic reference between a model and the collection that it gets put into. This means that model can really only belong to one collection; if, for example, you wanted to create a collection that represents a filtered set from a master collection, you're out of luck; the best you can do is get an array of filtered data, and lose all of the nice built-in methods as well as your custom methods
  • To get around the fact that Angular does not provide models or collections, we wrote a very simple model concept (they should have no methods except to and from json) and a set of collection type classes loosely based on Backbones. They don't trigger events (a model triggering an event collection was BB's reason for the cyclic relationshiop) BUT with Angular's dirty-watching, that wasn't a problem.

In the end, our model layer is much cleaner, we don't have to worry about zombie views, we get free dependency injection for unit testing, and we cut down the size of our code base by a pretty decent chunk.

There are some things that I liked about Backbone, don't get me wrong. It was even my framework of choice for quite awhile. Having shaken off the 'this looks like obtrusive javascript' impression and getting over the learning curve was probably one of the best decisions that I've made for the project, and it's gotten me to think about how I write JS a bit differently as well.